iCo*_*lor 5 elixir phoenix-framework
var socket = new Socket("localhost:4000")
socket.connect()
Run Code Online (Sandbox Code Playgroud)
返回 WebSocket connection to 'ws://localhost:4000/ws' failed: Error during WebSocket handshake: Unexpected response code: 404
但我确实在/ws端点上有套接字,对吗?
defmodule Sapphire.Endpoint do
use Phoenix.Endpoint, otp_app: :sapphire
socket "/ws", Sapphire.MomentSocket
plug Plug.Static,
at: "/", from: :sapphire, gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
if code_reloading? do
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
end
plug Plug.RequestId
plug Plug.Logger
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Poison
plug Plug.MethodOverride
plug Plug.Head
plug Plug.Session,
store: :cookie,
key: "_sapphire_key",
signing_salt: "hW1bFEcR"
plug Sapphire.Router
end
Run Code Online (Sandbox Code Playgroud)
它应该能够连接到该端点,但由于某种原因它根本无法访问它.
[info] Running Sapphire.Endpoint with Cowboy on http://localhost:4000
@JoséValim找到了解决方案.
我正在将phoenix.js库移植到coffeescript,并错过了路径的后缀应该是传输层的事实.在这种情况下,它/websocket最终需要在实现中.:)
| 归档时间: |
|
| 查看次数: |
1289 次 |
| 最近记录: |