WebSocket in the 2012 era: Event delivery and reconnect behavior
Model two-way WebSocket delivery alongside reconnects, ordering gaps and backpressure decisions owned by the application.
Archive retrospective · Topic year 2012
Separate the protocol from the delivery promise
RFC 6455, published in December 2011, defined a two-way WebSocket connection between client and server. The appeal for rapidly changing 2012 applications was receiving events without repeatedly opening a new HTTP request. The connection cannot guarantee that the application saw every event across a disconnect. Decide how the stream resumes, when a client becomes stale and how it should handle repeated messages. Those expectations belong in the application contract.
Work through an order status screen
Start with a consistent snapshot and apply events after that snapshot. If messages carry monotonic positions, the client can refresh its view or request an interval when it sees a gap. Applying a message twice should leave the intended last state. Do not make a critical state change durable only inside a browser connection. Use a source of truth that can answer a snapshot request after the page is reopened.
Budget for slow clients
A persistent connection does not justify an unbounded queue. When a slow client cannot keep up, a state-display stream may coalesce intermediate updates or require a replacement snapshot. An execution stream where every event is material needs a different policy. Measure the queue bound, reconnect count and replay capacity in the same test. Choose behavior based on what the consumer must see and how long the service can retain missed messages.
Rehearse a disconnect
Close the connection, produce an event and connect again. Check how both the intermediate event and the last state are represented. A mobile app returning from the background might not immediately detect that a connection closed. Use bounded retry delays and consider how many devices reconnect when service returns. Success is visible when the user can see a consistent fresh state after recovery, rather than merely when the socket opens.
Take a working example into real usage
A solution is not production-ready merely because a demo works. Test malformed input, access denial, network failure, timeouts, concurrency and retries. Keep API contracts explicit and display actionable errors in the interface. Verify both desktop and mobile layouts. Safe defaults, observability and reproducible tests reduce long-term maintenance cost.
Publish and maintain with measurements
Document the original problem, impacted screens and changed behavior before release. Test database compatibility, permissions and performance. A healthy HTTP response is not enough: validate rendered content and key user journeys. Retain application and data backups so a failed deployment can be rolled back responsibly.
Comments
No comments yet. Be the first to contribute.
Discussion question from the editor Does your application replay missing events or refresh the latest state after reconnecting?
Reading “WebSocket in the 2012 era: Event delivery and reconnect behavior” raised this question for me: compatibility and debugging impact deserve review.
Editor note: Product claims and measured outcomes should be assessed separately. A small pilot with defined metrics is a useful first step.
We should also discuss maintenance cost. An easy rollout does not guarantee trouble-free upgrades.
I would start with a pilot and measurable success criteria rather than assuming a launch means proven value.
✎ Write a comment