Hi. I made a websocket listener in an app platform worker to listen to the bluesky firehose.
My code works fine on Heroku. It stays up for days.
When I deployed to app platform it would start listening and processing events and then just hang after a minute or two.
It’s a golang program and I’m deploying a container. The same build process produced the container that I deployed to both platforms.
Does Digital Ocean throttle bandwidth or anything?
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.
Hey there, @lp10011! 👋
The App Platform doesn’t throttle bandwidth, there might be something else causing the connection to hang.
When using WebSockets, make sure your client is sending the following headers in the request:
Connection: Upgrade
– This header indicates that the client wants to keep the connection open and use it for non-HTTP protocols.Upgrade: websocket
– This header requests the server to switch from HTTP to the WebSocket protocol.Also make sure you’re deploying as a service, not a worker, so the port is exposed properly.
For reference, DigitalOcean has a handy Node.js WebSocket example that shows how to set up real-time bidirectional communication. While it’s in Node.js, the setup principles should be similar for your Golang app.
If your project is open source or if you have a minimal setup repo you can share, I’d be happy to try deploying it on my end to see if I can spot what might be going on!
On another note, you might consider deploying your WebSocket listener on a Droplet instead. With a Droplet, you get full root access, the flexibility to configure your server exactly how you need, and the ability to manage containers easily with tools like Docker. Check out the Docker Droplet on the Marketplace for a quick way to get started.
- Bobby