By Amila Deshan
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!
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:
You do not need to reference the internal port in your WebSocket client. Simply use the domain assigned by App Platform.
Regards
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.