随机额外的 websocket 连接到凤凰应用程序?

random extra websocket connection to phoenix app?

具有单个通道的简单用户 websocket。我几乎从 phoenix 指南中的 how to 部分复制了这个代码字。

第一个请求是我的 - 它包含来自 facebook 登录响应的用户身份验证令牌。 如您所见,这来自 phoenix.js 文件,并且工作正常...我能够发送和接收消息 - 没问题。

第二个似乎完全来自其他地方,我不知道为什么!?

frame.js 这不是我的文件,所以一定是某种 node_module 依赖关系的一部分,js 被压缩成一行并且不完全清晰。

我也每 5 秒左右在日志中得到一次:

phoenix_1  | [info] CONNECT GametimeWeb.UserSocket
phoenix_1  |   Transport: :websocket
phoenix_1  |   Connect Info: %{}
phoenix_1  |   Parameters: %{"token" => "", "vsn" => "2.0.0"}
phoenix_1  | :invalid - this is the response the socket returns I have jsut inspected it and printed to logs.
phoenix_1  | [debug] invalid
phoenix_1  | [info] Replied GametimeWeb.UserSocket :error

我做错了什么?

凤凰 1.4.10

用户套接字:

defmodule GametimeWeb.UserSocket do
  use Phoenix.Socket

  require Logger

  ## Channels
  channel "sports:*", GametimeWeb.SportsChannel

  # Socket params are passed from the client and can
  # be used to verify and authenticate a user. After
  # verification, you can put default assigns into
  # the socket that will be set for all channels, ie
  #
  #     {:ok, assign(socket, :user_id, verified_user_id)}
  #
  # To deny connection, return `:error`.
  #

  def connect(%{"token" => token}, socket) do
    # max_age: 1209600 is equivalent to two weeks in seconds
    case Phoenix.Token.verify(socket, "user socket salt", token, max_age: 1209600) do
      {:ok, user_id} ->
        {:ok, assign(socket, :user, user_id)}
      {:error, reason} ->
        Logger.debug IO.inspect(reason)
        :error
    end
  end

端点代码:

defmodule GametimeWeb.Endpoint do
  use Phoenix.Endpoint, otp_app: :gametime

  socket "/socket", GametimeWeb.UserSocket,
    websocket: true, # or list of options
    longpoll: false

这是实时重新加载功能的助手套接字。当MIX_ENVprod时不会打开。