File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ def _connect_to_mqtt(self) -> None:
112
112
" - device_registration :: connect :: created mqtt client. connecting.."
113
113
)
114
114
while not self ._auth_response_received :
115
- self ._mqtt .loop ()
115
+ self ._mqtt .loop (2 )
116
116
117
117
self ._logger .info (
118
118
" - device_registration :: connect :: on_connect must be fired. Connected ?"
@@ -139,7 +139,7 @@ def _start_registration(self) -> None:
139
139
while self ._operation_id is None and retry < 10 :
140
140
time .sleep (1 )
141
141
retry += 1
142
- self ._mqtt .loop ()
142
+ self ._mqtt .loop (2 )
143
143
144
144
if self ._operation_id is None :
145
145
raise DeviceRegistrationError (
@@ -159,7 +159,7 @@ def _wait_for_operation(self) -> None:
159
159
while self ._hostname is None and retry < 10 :
160
160
time .sleep (1 )
161
161
retry += 1
162
- self ._mqtt .loop ()
162
+ self ._mqtt .loop (2 )
163
163
164
164
if self ._hostname is None :
165
165
raise DeviceRegistrationError (
@@ -194,15 +194,15 @@ def register_device(self, expiry: int) -> str:
194
194
"&skn=registration"
195
195
)
196
196
197
- MQTT .set_socket (self ._socket , self ._iface )
198
-
199
197
self ._mqtt = MQTT .MQTT (
200
198
broker = constants .DPS_END_POINT ,
199
+ port = 8883 ,
201
200
username = username ,
202
201
password = auth_string ,
203
- port = 8883 ,
204
- keep_alive = 120 ,
205
202
client_id = self ._device_id ,
203
+ is_ssl = True ,
204
+ keep_alive = 120 ,
205
+ socket_pool = self ._socket ,
206
206
ssl_context = ssl .create_default_context (),
207
207
)
208
208
Original file line number Diff line number Diff line change @@ -120,8 +120,6 @@ def _gen_sas_token(self) -> str:
120
120
)
121
121
122
122
def _create_mqtt_client (self ) -> None :
123
- MQTT .set_socket (self ._socket , self ._iface )
124
-
125
123
log_text = (
126
124
f"- iot_mqtt :: _on_connect :: username = { self ._username } , password = "
127
125
+ f"{ self ._passwd } "
@@ -135,11 +133,13 @@ def _create_mqtt_client(self) -> None:
135
133
136
134
self ._mqtts = MQTT .MQTT (
137
135
broker = self ._hostname ,
136
+ port = 8883 ,
138
137
username = self ._username ,
139
138
password = self ._passwd ,
140
- port = 8883 ,
141
- keep_alive = 120 ,
142
139
client_id = self ._device_id ,
140
+ is_ssl = True ,
141
+ keep_alive = 120 ,
142
+ socket_pool = self ._socket ,
143
143
ssl_context = ssl .create_default_context (),
144
144
)
145
145
@@ -457,7 +457,7 @@ def loop(self) -> None:
457
457
if not self .is_connected ():
458
458
return
459
459
460
- self ._mqtts .loop ()
460
+ self ._mqtts .loop (2 )
461
461
gc .collect ()
462
462
463
463
def send_device_to_cloud_message (
You can’t perform that action at this time.
0 commit comments