Question

Websocket listener on Digital Ocean hangs after a minute or so

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?


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
December 18, 2024

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:

  1. Connection: Upgrade – This header indicates that the client wants to keep the connection open and use it for non-HTTP protocols.
  2. 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

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.