Search code examples
javaazureazure-iot-hubazure-iot-sdk

Microsoft Azure IoT hub (java) notifies a "Lost connection to the server. Reconnecting 0 time." after sending a message


I use the IoT Hub Java library to send messages between my devices and Microsoft Azure.

To connect I call

client = new DeviceClient(connString, protocol);
client.open();

And then, to send a message I call

client.sendEventAsync(message, callback, lockobj);

Then, my callback function is called when the message is sent.

However, and here is the problem, after calling sendEventAsync on my terminal appears infinitly the message Lost connection to the server. Reconnecting 0 time.

I've tried to close the connection after send the message and reopen it each time, but I think it's worst and the problem persists. Moreover, I've executed the test sample given by Azure (https://github.com/Azure-Samples/azure-iot-samples-java/archive/master.zip) and I have the same problem.

So my question is, is there a problem with the library (since the problem is present even with its code)? Or am I doing something wrong?

Thanks a lot!


Solution

  • I found the problem: today I was testing the same code as yesterday and everything worked well. So I have logged in Azure and I found this error message:

    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" }.

    So that, the problem was that I exeeded the messages quota. However, yesterday I was confused because Azure responded me with the message "OK_EMPTY" that means that everything is ok...