Is there a WebTransport connection closed event in aioquic?

111 views
Skip to first unread message

Jukka Jylänki

unread,
Jan 20, 2022, 12:02:43 PM1/20/22
to web-transport-dev
Hi all,

this might be a bit more aioquic related than WebTransport related(?), but given that the current server sample https://github.com/GoogleChrome/samples/blob/gh-pages/webtransport/webtransport_server.py is based on aioquic, I hope this is an appropriate forum for the question.

I would like to observe on my webtransport_server.py -derived server when a browser client disconnects, e.g. by closing the browser or navigating away from the page. Trying to search through the aioquic documentation and samples, I was unable to find such an event.

In my application I am only sending datagrams between the browser peers and the server (for a fast realtime gaming scenario), and I would like to know when a client disconnects so that I can immediately despawn their character from the game for all other peers (rather than let it time out on no activity)

Since sending datagrams is already a connectionful activity with WebTransport, I presume there should exist a possibility for such an event?

Thanks!
Jukka

Victor Vasiliev

unread,
Jan 20, 2022, 9:50:44 PM1/20/22
to Jukka Jylänki, web-transport-dev
Hi Jukka,

There are roughly two ways to close a WebTransport connection.

One is a "clean close".  It involves sending a FIN on the HTTP CONNECT request stream, typically before that you can send a capsule with an error code and an error message.  https://w3c.github.io/webtransport/#dom-webtransport-close would do that on the browser side, https://github.com/web-platform-tests/wpt/blob/master/tools/webtransport/h3/webtransport_h3_server.py#L281 is an example of doing that in Python with aioquic.

Another is by causing the HTTP CONNECT request stream to be reset, or the entire connection to go away.

I guess the tl;dr is "the WebTransport session is open as long as the CONNECT stream is open, and closing the stream in any way causes the session to close".

Hope this helps,
  Victor.

--
You received this message because you are subscribed to the Google Groups "web-transport-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web-transport-...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/web-transport-dev/22d618fe-fc6e-4fd2-bb39-b35b9252bc53n%40chromium.org.

Jukka Jylänki

unread,
Jan 21, 2022, 3:36:33 AM1/21/22
to Victor Vasiliev, web-transport-dev
Thanks Victor,

I saw the close() function in the webtransport h3 API, though that is an imperative verb/operation from the server side to go ahead and close the connection - what I was looking for instead is an event that would fire on the server side when the server notices that the browser side has called webTransport.close(). (or navigated away from the page, or quit the tab or the browser). Would there be such an event on the python server?

Victor Vasiliev

unread,
Jan 27, 2022, 10:28:09 PM1/27/22
to Jukka Jylänki, web-transport-dev
It should be a StreamDataReceived with end_stream=true for the CONNECT stream.

You will also eventually receive a ConnectionTerminated event for the connection, though due to some code missing, Chrome currently does not actually send CONNECTION_CLOSE, so that would be triggered via a timeout.

Yutaka Hirano

unread,
Jan 28, 2022, 3:41:21 AM1/28/22
to Victor Vasiliev, Jukka Jylänki, web-transport-dev
Reply all
Reply to author
Forward
0 new messages