← index #716PR #243
Related · high · value 2.316
QUERY · ISSUE

MQTT Disconnect socket write then close

openby AngeloFaticaopened 2023-08-16updated 2023-08-16

When there are network issues and I want to disconnect from mqtt client, the socket writes are blocking and cannot be changed (I havent been successful) so it will just hang on the self.sock.write(b"\xe0\0") line in the disconnect function of simple.py. Is this a necessary action, or can I not write that byte array and just close the socket so that I do not have to worry about hanging on the write indefinitely?

CANDIDATE · PULL REQUEST

umqtt.simple: add force_close parameter to disconnect() to ensure soc…

closedby jzafranopened 2017-12-30updated 2018-10-12

Add force_close argument to umqtt.simple.MQTTClient.disconnect() that, when set, ensures socket.close() is called even if there's an error while sending the disconnect message to the MQTT server.

The default behavior is the same as before - I'm tempted to change it; I believe it would be a better default, but I don't want to break any backward compatibility.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied