Is it possible to have a channel for a websocket created using cowboy2.
I have two sockets in my application. One of the websocket is using cowboy2. I am not able to create the channel for the websocket.
My websocket endpoint is /ws/feeds
I have this in my sys.config
{"/ws",
'Elixir.Phoenix.Endpoint.Cowboy2Handler',
{'Elixir.Phoenix.Transports.WebSocket',
{'Elixir.OctopusWeb.Endpoint',
'Elixir.OctopusWeb.FeedsSocket',websocket}}},
Endpoint.ex
socket "/ws", OctopusWeb.FeedsSocket,
websocket: false,
longpoll: false
FeedsSocket
defmodule OctopusWeb.FeedsSocket do
use Phoenix.Socket
require Logger
channel "feeds_channel", OctopusWeb.FeedsChannel
transport(
:websocket,
Phoenix.Transports.WebSocket,
serializer: [{HydraWeb.Web.Transports.BinarySerializer, "~> 1.0.0"}]
)
def connect(_params, socket) do
Logger.debug("feeds socket connected")
{:ok, socket}
end
def id(_socket), do: nil
end
Feedschannel.ex
defmodule OctopusWeb.FeedsChannel do
use Phoenix.Channel
require Logger
def join("feeds_channel", req, socket) do
Logger.debug("feeds channel connected")
{:ok, socket}
end
end
Please help me where I went wrong.