Skip to content

fix: Make WebSocket/WebRTC connection establishment more robust #3221

@sujalsalekar

Description

@sujalsalekar

Issue Description

While working with WebSocket and WebRTC transports, I noticed several reliability issues in connection establishment that could cause failures in production environments.

Problems Fixed

  1. WebSocket Issues:
  • No retry mechanism for failed connections
  • Basic error handling without proper cleanup
  • Missing connection timeouts
  1. WebRTC Issues:
  • ICE candidate gathering could hang indefinitely
  • No proper timeout for SDP answer
  • Connection state transitions weren't properly monitored

Solution

Added robust connection handling:

  • WebSocket: Added retry mechanism, proper timeouts, and better error handling
  • WebRTC: Added ICE gathering timeout (30s), connection timeout (60s), and proper state monitoring

Testing

Tested with:

  • Slow network conditions
  • Network interruptions
  • Various failure scenarios (ICE failures, timeout scenarios)

The changes significantly improve connection reliability in unstable network conditions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    need/triageNeeds initial labeling and prioritization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions