LiveView Elixir doesn't work in Cloudron but does locally
-
I have this function in my elixir code:
def handle_info(%{document_id: document_id}, socket) do {:noreply, push_patch(socket, to: ~p"/fact_check/result/?document_id=#{document_id}")} end
What it does: The user uploads a file using fact_check and gets forwarded to a waiting screen on /result. The document_id comes from Firestore and it should get appended to the link. Later, when the result has been processed, the page refreshes and shows the result.
This works on localhost and in a local docker container, but it doesn't work on Cloudron. There, the link doesn't get the ID, it stays the same, so the page would never update.
I have checked database connection and environment variables, everything works.
Any ideas what might be causing the issue? This must be a difference between a local docker container and cloudron.
-
-
@ekevu123 Could it be that the upload is not working properly ? Maybe it's relying on writing to some part in the file system and in Cloudron you cannot write there?
An idea:
cloudron debug --app xx
and then start the app manually. Does it work in debug mode? If so, it's most likely an issue with the app writing somewhere in the readonly filesystem. -
Actually, I have changed the code. I am using Phoenix Elixir and LiveView to render the results. I am polling every six seconds for a result from Firestore and once it becomes available, I am showing it. The data is stored in the memory only in socket assigns.
But if I got empty data, I would get an empty reaction. So, I need to assume that I am not receiving the trigger event.
The link change is not a trigger anymore. -
Now, this seems to be not working in my Elixir code:
Process.send_after(self(), :poll, 6_000)
The function is supposed to execute itself regularly every six seconds, which it does in a local docker container, but it doesn't on Cloudron, there it runs only ones initially. That's why my app doesn't catch any result on Cloudron. -
Given Cloudron is simply using docker, there is not much difference between running the container locally vs running on Cloudron. Maybe an idea is to run the container directly on the server like you are doing locally (i.e not as Cloudron app) and see if that works.