w3c / webtransport

WebTransport is a web API for flexible data transport
https://w3c.github.io/webtransport/
Other
848 stars 50 forks source link

Specify keep-alive and idle timeouts #614

Open MOZGIII opened 2 months ago

MOZGIII commented 2 months ago

The spec does not mention anything abut the keep-alive and idle timeouts.

The protocol itself permits setting protocol-level keep-alive, as well as the idle timeout. The application code should be able to, at the very least, request those parameters from the browser to learn what to expect, and ideally to request the parameters it would like during the transport setup.

I suggest allowing setting the optional keep-alive and idle timeouts, and throwing TypeError if they are not valid/acceptable. A reasonable fallback for the apps them would be to try negotiating the parameters by instantiating the WebTransport in a sequence, of attempts and catching the errors; with the ultimate fallback of not passing any keep-alive and idle timeout options.


Additions to WebTransport options:

Additions to the WebTransport API:

jan-ivar commented 2 months ago

WebTransport now uses the same HTTP/3 back-end as fetch. AFAIK fetch doesn't expose keep-alive and idle timeouts. Why should WebTransport?

Having concrete examples of use cases would be useful.

MOZGIII commented 2 months ago

fetch has different API, and it is intended for request/response operations that are typically short lived, while WebTransport can be long-lived and it starts to matter. Note that it could also benefit from the ability to tweak keepalive / idle parameters - although it is not so much of an issue there.

WebTransport could be used for a mobile game for instance, where the application would want to know and/or tweak the timings of the keepalive to allow the session to keep idle connections longer as users can move around. Think about users going into a tunnel to catch a pokemon and then going out to resume where they left off.

Another example is an ngrok-like tunneling app, where the users and service providers might want to agree to let the session live for hours when idle, as this can be important for when the user moves locations (i.e. you go from the office to home while maintaining the same session).