Description
Specification
After the QUIC connection is established, there's a max idle timeout. Nothing actually keeps the connection alive. If there's no activity on the connection either by stream data or datagram data, then the connection will timeout and be destroyed. Once destroyed, the QUICClient
is destroyed, or the QUICServer
removes it from the connection map.
We should have a interval loop that keeps the connection alive. This will be important for any connection that we need to maintain the NAT mappings. Which usually activity under 20 seconds.
One way to do this is with the send_ack_eliciting method. This method will queue up a PING frame if it detects there's nothing in the send queue that will keep the connection alive (and by nothing we mean something that will trigger an acknowledgement from the remote end).
I imagine that this can be done from both ends, the client and server. So both sides are capable of sending a PING frame and elicit an acknowledgement.
The function call is a noop if there's stuff ihttps://github.com//issues/1#issuecomment-1501236254n the queue that will keep the connection alive anyway.
We should add in a keepaliveIntervalTime
that maintains the connection liveness to QUICConnection
. This can be added to the config
, although it's not actually used by the buildQuicheConfig
.
Alternatively it can be an extra parameter to the QUICConnection
itself.
I think this loop will be rather easy. It can be a setTimeout
loop that just calls that function repeatedly. However this loop can only start once the connection is established, and the loop must not be running when the connection is closing or draining.
Additional context
- Keep Alive + Ping cloudflare/quiche#635 - original issue closed by the introduction of
send_ack_eliciting
- https://datatracker.ietf.org/doc/html/rfc9000#name-ping-frames - spec about the PING frames
- Create QUIC library that can be exposed to JS and uses the Node
dgram
module #1 (comment) - original comment about bringing this in
Tasks
- 1. Introduce
keepAliveTime
option toQUICConnection
, propagate from bothQUICClient
andQUICServer
. - 2. Ensure that the loop is only running after being established and before it is closed or draining.
- 3. Test that a connection is kept alive even during the idle timeout.
- 4. Note that by specifying such a thing this does not conflict with the idle timeout. This is because, the remote end might still be broken or not responding, in that case, the idle timeout will still be hit and the connection will timeout.
- 5. Use it in PK and make sure it's less than 5 seconds.
- 6. Test what happens if it is enabled on both client and server, what do we see on the wireshark monitor?