namxam

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 :smiley:

Marked As Solved

namxam

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.

Where Next?

Popular in Questions Top

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
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
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

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
lanycrost
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
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
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

We're in Beta

About us Mission Statement