-
Notifications
You must be signed in to change notification settings - Fork 736
Send multiple pings during large downloads, resetting self._ping_t #923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2174,6 +2174,8 @@ def loop_misc(self) -> MQTTErrorCode: | |||||||
|
|
||||||||
| return MQTTErrorCode.MQTT_ERR_SUCCESS | ||||||||
|
|
||||||||
|
|
||||||||
|
|
||||||||
| def max_inflight_messages_set(self, inflight: int) -> None: | ||||||||
| """Set the maximum number of messages with QoS>0 that can be part way | ||||||||
| through their network flow at once. Defaults to 20.""" | ||||||||
|
|
@@ -3274,7 +3276,7 @@ def _check_keepalive(self) -> None: | |||||||
| last_msg_in = self._last_msg_in | ||||||||
|
|
||||||||
| if self._sock is not None and (now - last_msg_out >= self._keepalive or now - last_msg_in >= self._keepalive): | ||||||||
| if self._state == _ConnectionState.MQTT_CS_CONNECTED and self._ping_t == 0: | ||||||||
| if self._state == _ConnectionState.MQTT_CS_CONNECTED and (self._ping_t == 0 or now - last_msg_in < self.keepalive): | ||||||||
| try: | ||||||||
| self._send_pingreq() | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while writting above comment I realized one point which is unclear if it really hold:
I'm not totally sure this is true. Because it only true if loop_write is called, which if behind a condition ( So I think we should protect this call to pingreq:
Suggested change
In any case, I don't see a protocol requirement to send a PINGREQ less than keepalive after previous one. The only requirement is that we need to send any MQTT packet every keepalive, to ensure broker don't disconnect us. But we are never required to send PINGREQ sooner. |
||||||||
| except Exception: | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said in #914 (comment), I think
last_msg_inshould be renamed and reworked intolast_bytes_received. It should count the last time a bytes was received on the network (i.e. as soon asself._sock.recvreturn a length >= 1).But when the change of
last_bytes_receivedis done, I think it will meet required the translation of MQTT spec I write in #914:oradded by this PR will cause a new PINGREQ to be sent (and since PINGREQ update lsg_msg_out, we won't flood PINGREQ)oraddedoris capped by keepalive