当前,我正在为IoT环境传感器制作原型,并使用AWS IoT Core作为消息代理。我已经完成了此设置,正如您所看到的,我将漏极频率提高到了10。
def setupMQTTConnect(self):
self.mqtt = AWSIoTMQTTClient(self.hostname)
self.mqtt.configureCredentials(self.rootca, self.privkey, self.cert)
self.mqtt.configureEndpoint(self.endpoint, 8883)
self.mqtt.configureAutoReconnectBackoffTime(1, 32, 20)
self.mqtt.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueing
self.mqtt.configureDrainingFrequency(10) # Draining: 10 Hz
self.mqtt.configureConnectDisconnectTimeout(10) # 10 sec
self.mqtt.configureMQTTOperationTimeout(5) # 5 sec
return self.mqtt.connect()
def send(self, topic, data):
message = {}
message['message'] = data
message['timestamp'] = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
message['hostname'] = self.hostname
messageJson = json.dumps(message)
try:
publish = self.mqtt.publish(topic, messageJson, 0)
except Exception as e:
self.log.error(e)
print(e)
我关闭了wlan接口5个小时,然后又将其重新打开以使队列清空,以10Hz的频率清空队列大约需要12个小时。安全到多高才能更快地排水?我很困惑为什么要花这么长时间排掉队列。