Skip to content

Commit c85a97d

Browse files
authored
Merge pull request #425 from ruoshui1314/timeout
Add timeout when connecting the broker server
2 parents 203f72f + 0d7b393 commit c85a97d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/paho/mqtt/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3517,12 +3517,12 @@ def _create_socket_connection(self):
35173517
if sys.version_info < (2, 7) or (3, 0) < sys.version_info < (3, 2):
35183518
# Have to short-circuit here because of unsupported source_address
35193519
# param in earlier Python versions.
3520-
return socket.create_connection(addr)
3520+
return socket.create_connection(addr, timeout=self._keepalive)
35213521

35223522
if proxy:
3523-
return socks.create_connection(addr, source_address=source, **proxy)
3523+
return socks.create_connection(addr, source_address=source, timeout=self._keepalive, **proxy)
35243524
else:
3525-
return socket.create_connection(addr, source_address=source)
3525+
return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
35263526

35273527

35283528
# Compatibility class for easy porting from mosquitto.py.

0 commit comments

Comments
 (0)