Skip to content

Commit d6faaf8

Browse files
prabhu-yudpgeorge
authored andcommitted
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.
1 parent 68e3e07 commit d6faaf8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

micropython/umqtt.simple/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
metadata(description="Lightweight MQTT client for MicroPython.", version="1.4.0")
1+
metadata(description="Lightweight MQTT client for MicroPython.", version="1.5.0")
22

33
# Originally written by Paul Sokolovsky.
44

micropython/umqtt.simple/umqtt/simple.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ def set_last_will(self, topic, msg, retain=False, qos=0):
6060
self.lw_qos = qos
6161
self.lw_retain = retain
6262

63-
def connect(self, clean_session=True):
63+
def connect(self, clean_session=True, timeout=None):
6464
self.sock = socket.socket()
65+
self.sock.settimeout(timeout)
6566
addr = socket.getaddrinfo(self.server, self.port)[0][-1]
6667
self.sock.connect(addr)
6768
if self.ssl:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy