我使用 IoT 中心 Java 库在我的设备和 Microsoft Azure 之间发送消息。
要连接,我打电话
client = new DeviceClient(connString, protocol);
client.open();
然后,发送一条消息,我打电话
client.sendEventAsync(message, callback, lockobj);
然后,发送消息时会调用我的回调
函数。
但是,问题在于,在我的终端上调用 sendEventAsync
后,无限地出现消息与服务器的连接丢失。重新连接 0 次。
我尝试在发送消息后关闭连接并每次重新打开它,但我认为这是最糟糕的,问题仍然存在。而且,我执行了Azure(https://github.com/Azure-Samples/azure-iot-samples-java/archive/master.zip)给出的测试样本,也遇到了同样的问题。
所以我的问题是,该库是否存在问题(因为即使其代码也存在问题)?还是我做错了什么?
非常感谢!
最佳答案
我发现了问题:今天我测试了与昨天相同的代码,一切正常。所以我登录了Azure,发现了这个错误消息:
There was an error querying devices: Forbidden:{ "Message": "ErrorCode:IotHubQuotaExceeded;Total number of messages on IotHub '[..]' exceeded the allocated quota. Max allowed message count : '8000', current message count : '20107'. Send and Receive operations are blocked for this hub until the next UTC day. Consider increasing the units for this hub to increase the quota.", "ExceptionMessage": "Tracking ID:[..]-TimeStamp:10/17/2018 08:48:37" }.
所以,问题是我超出了消息配额。然而,昨天我很困惑,因为 Azure 回复了我消息“OK_EMPTY”,这意味着一切都好......
关于java - Microsoft Azure IoT 中心 (java) 发送消息后通知 "Lost connection to the server. Reconnecting 0 time.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52839637/