lexus2k/tinyproto

Connection breaks down if nothing is sent for >= keep alive timeout

chenlijun99 opened this issue · 2 comments

I would expect Tinyproto to schedule some S frames as keep alive frames.

Tinyproto already has this:

else if ( __time_passed_since_last_frame_received(handle, peer) > handle->ka_timeout )

If you consider a bug, let me know

Hi. Sorry for the lack of feedback.

Indeed, there is already a mechanism to send keep alive frames. I can see that sometimes it works, sometimes it doesn't. If I understand the code correctly, once a keep alive frame has been sent, if tiny_fd_connected_check_idle_timeout is immediately re-called (because tiny_fd_get_tx_data is immediately re-called), before the response to the keep alive frame is received, then we immediately enter this branch

if ( !handle->peers[peer].ka_confirmed )
{
LOG(TINY_LOG_CRIT, "[%p] No keep alive after timeout\n", handle);
__switch_to_disconnected_state(handle, peer);
}

and disconnection is asserted.

Maybe a sort of keepalive response timeout should be considered?