kopia lustrzana https://github.com/micropython/micropython-lib
umqtt.simple: Add optional socket timeout to connect method.
If there are any network issues, mqtt will block on the socket non-deterministically. This commit introduces a `timeout` option which can be used to set a finite timeout on the socket. Upon any issue, mqtth lib will throw exception.pull/890/head
rodzic
68e3e07bc7
commit
d6faaf8472
|
@ -1,4 +1,4 @@
|
|||
metadata(description="Lightweight MQTT client for MicroPython.", version="1.4.0")
|
||||
metadata(description="Lightweight MQTT client for MicroPython.", version="1.5.0")
|
||||
|
||||
# Originally written by Paul Sokolovsky.
|
||||
|
||||
|
|
|
@ -60,8 +60,9 @@ class MQTTClient:
|
|||
self.lw_qos = qos
|
||||
self.lw_retain = retain
|
||||
|
||||
def connect(self, clean_session=True):
|
||||
def connect(self, clean_session=True, timeout=None):
|
||||
self.sock = socket.socket()
|
||||
self.sock.settimeout(timeout)
|
||||
addr = socket.getaddrinfo(self.server, self.port)[0][-1]
|
||||
self.sock.connect(addr)
|
||||
if self.ssl:
|
||||
|
|
Ładowanie…
Reference in New Issue