0

I'm trying to connect from a JS application to a websocket connection in Phoenix/Elixir, however, now matter what I try, I get

ERROR:

[info] GET /socket/websocket
[debug] ** (Phoenix.Router.NoRouteError) no route found for GET /socket/websocket (AirtameZap.Router)

From the Javascript client I connect in the following way:

socket = new Socket("ws://example/socket", {});
socket.connect();
socket.channel("zap:all")
...

Here are the source files for the backend service:

/lib/airtame_zap/endpoint.ex

defmodule AirtameZap.Endpoint do
 use Phoenix.Endpoint, otp_app: :airtame_zap

 socket "/socket", AirtameZap.ZapSocket
 ...

/web/channels/zap_socket.ex

defmodule AirtameZap.ZapSocket do
   use Phoenix.Socket

   channel "zap:*", AirtameZap.ZapChannel

   transport :websocket, Phoenix.Transports.WebSocket
   ...

   def connect(_params, socket) do
      {:ok, socket}
   end
   def id(_socket), do: nil
end

/web/channels/zap_channel.ex

defmodule AirtameZap.ZapChannel do
   use Phoenix.Channel

   def join("zap:all", _message, socket) do
     {:ok, socket}
   end
 end

Any ideas? I found this reply Phoenix: Trying to connect to Channel but getting a not Route found for GET /websocket error but it didn't help

Community
  • 1
  • 1
ellimist
  • 586
  • 3
  • 12

0 Answers0