namxam
Phoenix.js not reconnecting when server runs in Docker container
I have a nodejs application which uses the phoenix javascript package to connect to a phoenix application. It works fine as long as I do not restart the phoenix application. Once I restart it, I have to manually restart the node app as well.
I tried various setups, but it seems to be an issue with docker. Whenever I start the app locally (iex -S mix phx.server, mix phx.server, mix release && _…, prod and dev) it works as expected. After shutting down my phoenix app, node tries to reconnect. But as soon as I start the release in my docker container, node does not try to reconnect any more.
I also created a minimal web app which does show the same symptoms. Just to make sure, that it is not related to the node js websocket libraries.
UPDATE: I created a new socket + channel for testing purposes and it seems to be working there. So there has to be something wrong with my socket or channel implementation.
UPDATE: By carefully removing code, it boiled down to an issue with Phoenix.Tracker.
When removing the Phoenix.Tracker.track(…) code it works without any issues.
Has anyone an idea what might cause this behaviour. I guess I made a mistake but I have no idea which ![]()
Marked As Solved
namxam
Well, I found the issue and it all boiled down to the fact, that I had my Phoenix.Tracker started after my Endpoint implementation. I still don’t know why this only happens when packaging in a docker container, but it now works.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









