private-octopus / picoquic

Minimal implementation of the QUIC protocol
MIT License
523 stars 153 forks source link

Add log and callback on idle timeout #1584

Closed TimEvens closed 7 months ago

TimEvens commented 7 months ago

Today we only receive picoquic_callback_close callback (https://github.com/private-octopus/picoquic/blob/master/picoquic/sender.c#L3772) when a connection abruptly goes away (force terminate, network loss, ...). If a connection drops due to idle timeout, we would like to log it and handle reconnect differently than a protocol error, transport error, etc.

Would it be possible to add a callback or field to indicate the reason for picoquic_callback_close?

Below shows our logs on idle timeout. We don't know why it was disconnected.

2023-11-27T08:59:27.443107 [INFO] [QUIC] [PQIC] icoquic/loss_recovery.c:520 [picoquic_retransmit_needed_packet]: Too many retransmits of packet number 90143, disconnect
2023-11-27T08:59:29.443086 [INFO] [QUIC] [PQIC] icoquic/loss_recovery.c:497 [picoquic_retransmit_needed_packet]: Too many data retransmits, abandon path

2023-11-27T08:59:29.443264 [INFO] [QUIC] [PQIC] icoquic/loss_recovery.c:520 [picoquic_retransmit_needed_packet]: Too many retransmits of packet number 90145, disconnect

##### Below is when idle timeout happens ######
2023-11-27T08:59:29.688904 [INFO] [QUIC] Closing connection stream_id: 0 (dgram)
2023-11-27T08:59:29.688977 [INFO] [QUIC] Delete stream context for stream 0 (dgram)
2023-11-27T08:59:29.689017 [INFO] [ECHO] Connection state change context: 5494578688, 3
huitema commented 7 months ago

Upon receiving the "close" callback, did you try using the existing API:

/* Retrieve the error codes after failure of a connection or of a stream */

uint64_t picoquic_get_local_error(picoquic_cnx_t* cnx)
{
    return cnx->local_error;
}

uint64_t picoquic_get_remote_error(picoquic_cnx_t* cnx)
{
    return cnx->remote_error;
}

uint64_t picoquic_get_application_error(picoquic_cnx_t* cnx)
{
    return cnx->remote_application_error;
}
TimEvens commented 7 months ago

@huitema , thank you. I missed that. it does work. I am receiving 1075, which is PICOQUIC_ERROR_IDLE_TIMEOUT.