Hi,
I have a Python script that I want to deploy as an app on DigitalOcean. I already created that script in the APP Platform App. Then the app platform url is going to use as a Websocket. After 5 minutes, I can see my an error message saying " Connection Closed". Because of that my front end which is connected to the websocket has an issue saying “Websocket Connection Closed”.
Because of the connection closed after 5 minutes, I can’t do anything with my websocket. Can anyone please help me to understand how to make my app to run 247365 constantly. I have assigned a custom domain to my app as well.
This is the app run command
uvicorn main:app --host 0.0.0.0 --port 8080 --timeout-keep-alive 300000 --ws-ping-interval 30 --ws-ping-timeout 30
This is an urgent matter. Please help me anyone asap.
Thank you.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Heya, @amiladeshan
When defining the WebSocket server (
uvicorn
in your case), you specify the internal port (e.g., 8080). However, externally, App Platform exposes your app on port 443 (via HTTPS). The platform handles the mapping between the internal port and external HTTPS endpoint.A similar question was asked before in the community:
https://www.digitalocean.com/community/questions/how-do-i-run-a-web-service-with-websockets-on-app-platform
You do not need to reference the internal port in your WebSocket client. Simply use the domain assigned by App Platform.
Regards