LiveView Elixir doesn't work in Cloudron but does locally
-
wrote on Mar 1, 2024, 5:32 AM last edited by ekevu123 Mar 3, 2024, 3:48 PM
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. -
wrote on Mar 3, 2024, 2:18 PM last edited by
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. -
wrote on Mar 4, 2024, 10:25 AM last edited by
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. -
wrote on Mar 4, 2024, 10:42 AM last edited by
I could try, of course, but since it works in a docker container locally, and not on Cloudron, I wonder what direction can I take in general to solve this? I got it working locally, so I think I have matched all dependencies etc.
-
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.
-
wrote on Mar 4, 2024, 11:45 AM last edited by
Yes, it doesn't work on a plain Ubuntu server either.
But why? What's the difference between localhost on my computer and a Ubuntu server online? I am even running Ubuntu. -
wrote on Mar 4, 2024, 12:38 PM last edited by
Yes, makes sense, I am asking in the elixir forum. Thank you still for being here!