Skip to content

Active closure of socket upon reconnection#15

Merged
fizista merged 2 commits intofizista:masterfrom
elvis-epx:active-dis
Nov 24, 2022
Merged

Active closure of socket upon reconnection#15
fizista merged 2 commits intofizista:masterfrom
elvis-epx:active-dis

Conversation

@elvis-epx
Copy link
Contributor

This PR explicitly calls disconnect() before connect(), and makes sure disconnect() is idempotent and does nos raise exceptions.

At least in ESP32, connection sockets are limited in number (8 or 10) and they pile up if not explicitly closed and/or garbage-collected. Calling connect() a number of times on umqtt.simple or umqtt.simple2 without explicit closure/gc eventually fails.

This PR explicitly calls disconnect() before connect(), and makes sure
disconnect() is idempotent and does nos raise exceptions.

At least in ESP32, connection sockets are limited in number (8 or 10)
and they pile up if not explicitly closed and/or garbage-collected.
Calling connect() a number of times on umqtt.simple or umqtt.simple2
without explicit closure/gc eventually fails.
If connect() raises an exception, it may happen that self.sock
contains a socket but the poller members are still None.
@fizista fizista merged commit 7c2ffd3 into fizista:master Nov 24, 2022
@fizista
Copy link
Owner

fizista commented Nov 24, 2022

Thank you.

@dgoadby
Copy link

dgoadby commented Nov 25, 2022

Thanks from me too. I just ran into this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants