|
21 | 21 | import iso8601
|
22 | 22 | from datetime import datetime
|
23 | 23 |
|
24 |
| -__version__ = "0.0.5" |
| 24 | +__version__ = "0.0.6" |
25 | 25 |
|
26 | 26 | class Message:
|
27 | 27 | def __init__(self, message):
|
@@ -105,9 +105,9 @@ def __logAndRaiseException(self, e):
|
105 | 105 | def connect(self):
|
106 | 106 | self.logger.debug("Connecting... (address = %s, port = %s, clientId = %s, username = %s, password = %s)" % (self.address, self.port, self.clientId, self.username, self.password))
|
107 | 107 | try:
|
108 |
| - self.client.loop_start() |
109 | 108 | self.connectEvent.clear()
|
110 | 109 | self.client.connect(self.address, port=self.port, keepalive=self.keepAlive)
|
| 110 | + self.client.loop_start() |
111 | 111 | if not self.connectEvent.wait(timeout=10):
|
112 | 112 | self.__logAndRaiseException(ConnectionException("Operation timed out connecting to the IBM Internet of Things service: %s" % (self.address)))
|
113 | 113 |
|
@@ -143,12 +143,12 @@ def on_log(self, mqttc, obj, level, string):
|
143 | 143 | 4: Refused - bad user name or password (MQTT v3.1 broker only)
|
144 | 144 | 5: Refused - not authorised (MQTT v3.1 broker only)
|
145 | 145 | '''
|
146 |
| - def on_connect(self, mosq, obj, rc): |
| 146 | + def on_connect(self, client, userdata, flags, rc): |
147 | 147 | if rc == 0:
|
148 | 148 | self.connectEvent.set()
|
149 | 149 | self.logger.info("Connected successfully")
|
150 | 150 | elif rc == 5:
|
151 |
| - self.__logAndRaiseException(ConnectionException("Not authorized: s (%s, %s)" % (self.clientId, self.username, self.password))) |
| 151 | + self.__logAndRaiseException(ConnectionException("Not authorized: s (%s, %s, %s)" % (self.clientId, self.username, self.password))) |
152 | 152 | else:
|
153 | 153 | self.__logAndRaiseException(ConnectionException("Connection failed: RC= %s" % (rc)))
|
154 | 154 |
|
|
0 commit comments