WebSocket API Overview
Learn how to establish and maintain real-time connections with Pragma’s WebSocket API
WebSockets provide a persistent connection between your application and Pragma’s servers, allowing for real-time data streaming with minimal latency.
Connection Endpoints
We recommend using the Development endpoint while building and testing your application.
Authentication
All WebSocket connections are currently public and open without authentication.
In the near future, WebSocket connections will require authentication using an API key similar to the REST API. We recommend designing your implementation with this upcoming change in mind.
Connection Management
Connection Lifecycle
Understanding how to properly establish, maintain, and close WebSocket connections is essential for reliable real-time data streaming.
Reconnection Strategy
Implement proper reconnection logic to handle network interruptions and server-initiated disconnects gracefully.
Connection Limits
Best Practices
Implement proper error handling
Always include robust error handling and reconnection logic in your WebSocket implementation. Network disconnections and server-side issues can occur, and your application should gracefully recover from these scenarios.
Use ping/pong messages
Send regular ping messages (every 30 seconds) to keep the connection alive and detect stale connections early.
Monitor connection health
Track connection state and performance metrics in your application to ensure reliable data delivery and prompt detection of issues.
Implement backoff strategy
When reconnecting after failures, use an exponential backoff strategy to avoid overwhelming the server during outages.
Common Issues & Troubleshooting
Was this page helpful?