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
Would this work?
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 
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 
Cheers,
Ben
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







