API Gateway WebSocket Connections Randomly Disconnect

I’m using API Gateway WebSockets for an app that needs to work in real time, but users are saying they keep getting disconnected.

It doesn’t always happen at the same time; sometimes it happens after 30 seconds, and other times after 20 minutes.

CloudWatch logging doesn’t show throttling or backend errors, and my WebSocket idle timeout is set up correctly.

Why it might be happening:

  • Problems with the network on the client side or at the AWS edge location
  • Not properly cleaning up old connection IDs
  • API Gateway throttling bursts that aren’t logged
  • Lambda backend is taking too long to answer
  • Integration or routing latency that makes connections drop without a sound

Has anyone experienced intermittent WebSocket drops on API Gateway?

What changes to your settings or debugging steps helped you fix WebSocket connections?

Please could you clarify the connection of your post to PsychoPy/Pavlovia?