Modify a check to make sure that keep alive is sent even when data is in the buffer #223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The coreMQTT library is responsible for sending the keep alive messages to the broker when there is no transaction of data between the broker and the client.
The check (
if( status == MQTTNoDataAvailable )
) for that condition is not correct anymore (since PR #218) because this condition is only set when there is no data in the socket AND none in the receive buffer. Thus, if there is any data in the receive buffer, it would prevent the library from sending a ping.But for the matter of keep alive, the server does not care whether there is data in the buffer or not. It only cares when was the last TCP transaction with the client which can be depicted by the data in the socket.
This PR updates the
if
condition such that the sending of keep alive is only based on the reception of data or lack thereof from the socket. The change is as follows: