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
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database.
Dep...
New
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
Hey guys.
I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Sometimes I want to check if the input into a function is not a blank string.
My first approach:
defmodule Example do
def do_stuff(s...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Other popular topics
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
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
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I'm writing a test for one of t...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
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
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New








