Skip to content

Continue resumable sockets across transports - #6930

Open
SteffenDE wants to merge 3 commits into
sd-resumable-websocketfrom
sd-resumable-across-transports
Open

SteffenDE wants to merge 3 commits into
sd-resumable-websocketfrom
sd-resumable-across-transports

Conversation

@SteffenDE

Copy link
Copy Markdown
Member

A socket that started over a WebSocket can now continue with long polling, and the other way around, as both transports resume the same session with the same message numbers.

On the server, a client switches transports by resuming the session over the other one, which the socket checks with resume/3. The session then detaches the WebSocket it has, and long-poll requests without a resume keep getting 410 while the client uses a WebSocket. The session waits for the client with the window of the transport it continues with, so that a poll waiting for messages does not look like inactivity. Binary messages of a session that started over a WebSocket reach long polling base64-encoded in an object, like all binary long-poll messages.

On the client, ResumableWebSocket falls back to long polling when it cannot resume the session over a WebSocket within the longPollFallbackMs option of the socket, for example when a proxy stops allowing WebSockets. It hands the session to a LongPoll, which resumes it with the token and the number of the last message received, and sends the messages the server did not confirm. The socket keeps its connection, and channels stay joined.

Parts of this come from #6887.

@SteffenDE
SteffenDE added this pull request to stack #6927 November 26, 2026 12:11
@SteffenDE
SteffenDE force-pushed the sd-resumable-across-transports branch from 3dad3a7 to f41a1d0 Compare November 30, 2026 16:36
@SteffenDE
SteffenDE force-pushed the sd-resumable-across-transports branch 4 times, most recently from 797d289 to 5b7228a Compare December 3, 2026 14:55
A socket that started over a WebSocket can now continue with long
polling, and the other way around, as both transports resume the same
session with the same message numbers.

On the server, a client switches transports by resuming the session
over the other one, which the socket checks with resume/3. The session
then detaches the WebSocket it has, and long-poll requests without a
resume keep getting 410 while the client uses a WebSocket. The session
waits for the client with the window of the transport it continues
with, so that a poll waiting for messages does not look like
inactivity. Binary messages of a session that started over a WebSocket
reach long polling base64-encoded in an object, like all binary
long-poll messages.

On the client, ResumableWebSocket falls back to long polling when it
cannot resume the session over a WebSocket within the longPollFallbackMs
option of the socket, for example when a proxy stops allowing
WebSockets. It hands the session to a LongPoll, which resumes it with
the token and the number of the last message received, and sends the
messages the server did not confirm. The socket keeps its connection,
and channels stay joined.

Parts of this come from #6887.
@SteffenDE
SteffenDE force-pushed the sd-resumable-across-transports branch from 5b7228a to 4340489 Compare December 3, 2026 15:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant