quinn
quinn copied to clipboard
feat: add event and function to wait for resumption tickets
Depends on https://github.com/rustls/rustls/pull/2476 (merged but not released)
This adds a new connection event to quinn-proto: ResumptionTicketsReceived. This event is emitted if TLS13 resumption tickets were received. The event is emitted at most once and only on the client side.
In quinn, this adds a new function resumption_tickets_received, which returns a future that completes once the connection received TLS resumption tickets. The future will be pending forever on the server side. On the client side, it will complete immediately if tickets were already received, or complete once tickets are received, or stay pending forever if the server does not send us tickets.
The PR depends on this rustls PR to expose the number of TLS13 resumption tickets that were received so far.
This new feature is useful when doing many short-lived 0rtt connections: It may happen easily that the application-level data exchange is done in a single roundtrip (eg when doing a single, small request-response) but the resumption tickets from the server are only sent in the next packet. If closing the connection after the application data exchange completes, we did not yet receive the new tickets and thus cannot issue further 0rtt connections when our initial tickets are consumed. With this new API, a client-side 0rtt connection can wait for conn.resumption_tickets_received() before closing the connection (should also apply a timeout in case the server does not send any tickets). Thus, it can issue further 0rtt connections without having to go back to 1rtt inbetween.