sc4224

sc4224

Connecting Golang microservice to Phoenix channel through Gorilla Websockets

Is it possible to connect to a phoenix channel from a separate microservice written in go? I’ve looked at go websockets, but not sure how to implement as there aren’t any examples related to phoenix channels

Most Liked

sc4224

sc4224

Would this work?

nerdyworm

nerdyworm

I’ve used that package previously and it worked. However I scrapped and wrote my own (sorry closed source) due to the need for a re-connection policy and a fallback to the long poll transport. I’m still using the gorilla websocket package for the raw connection parts though.

So yes, completely possible and not all that hard :slight_smile:

The best place to look at how to write the client code is the phoenix.js socket code. It contains all the nitty gritty details you need to implement it correctly.

Pro Tip: Don’t forget to send heartbeats with an idle connection :slight_smile:

Cheers,
Ben

sc4224

sc4224

So I made some headway thanks to somebody from stackoverflow. I’m just wondering if you had experience debugging the Join function from the golang side of things.

Currently I’m receiving an error from phoenix:

Ranch protocol #PID<0.437.0> of listener MyAppWeb.Endpoint.HTTP (cowboy_protocol) terminated
phoenix_1  | ** (exit) exited in: Phoenix.Endpoint.CowboyWebSocket.resume()
phoenix_1  |     ** (EXIT) an exception was raised:
phoenix_1  |         ** (FunctionClauseError) no function clause matching in 
Phoenix.Socket.Message.from_map!/1

However I’m unable to decipher what is causing this issue. I have a Join function that I call from the simonsargent gophoenix library. I have no problems connecting to the socket client on golang, but joining a channel raises the error above and my golang microservice disconnects from the socket immediately

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "eq...
New
bsollish-terakeet
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
script
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
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30840 112
New
Fl4m3Ph03n1x
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
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47849 226
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement