VBandarupalli
Can we have Phoenix Channels for a cowboy2 websocket handlers
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.
First Post!
Exadra37
Change websocket to true.
Popular in Questions
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
I have a list say
x = ["23gh", "56kh", "97mh"]
I would like to pass each element to Val in each iteration.
Say, in iteration 1 -------...
New
Hi all
I want to have a unix time, from the current time plus 1 hour.
DateTime.now + 1 hour
How to get it in elixir?
Thanks
New
In AR this is so simple
@articles = current_user.articles
How to do in Ecto?
def index(conn, _params) do
current_user = conn.assig...
New
Other popular topics
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
I would like to know what is the best IDE for elixir development?
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
by Lance Halvorsen
Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New








