"Connection refused: server unavailable" error while connecting Arduino MKRGSM with Azure IoT Hub

Sahithya 1 Reputation point
2021-07-30T10:04:23.71+00:00

I am registering my Arduino MKRGSM board with Azure Iot Hub by following this link:

https://create.arduino.cc/projecthub/Arduino_Genuino/securely-connecting-an-arduino-nb-1500-to-azure-iot-hub-af6470

Arduino MKRGSM 1400 device is successfully registered in the IoT Hub. but, when I am trying to connect the MKRGSM board to IoT Hub with the example provided in the arduino IDE,
Arduino IDE using File -> Examples -> Arduino Cloud Provider Examples -> AzureIoTHub-> Azure_IoT_Hub_GSM

In the serial monitor, I could see that, the board is getting connected to cellular network successfully, but whenever it is attempting to connect with MQTT, I am getting an error 3(Connection refused:Server unavailable) from the mqttClient.connect(broker, 8883). what would be the reason for this error?
But after few hours(around 10 hours) of registering the device in IoT Hub, i could able to communicate with the device without any error.

why it is taking time to connect with IoT Hub? can anyone suggest me to get through this. Thanks.

Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
383 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,128 questions
{count} votes

1 answer

Sort by: Most helpful
  1. QuantumCache 20,031 Reputation points
    2021-09-29T22:08:44.803+00:00

    Hello all,

    As a troubleshooting step in this scenario, we recommend using a new Azure IoTHub created and connect another real IoT Device example using the: IoT Plug and Play app quickly.https://play.google.com/store/apps/details?id=com.iot_pnp&hl=en_IN&gl=US

    and connect to the IoT hub. Then send the telemetry messages. It can be monitored using IoT explorer Install and use Azure IoT explorer | Microsoft Learn

    Please comment in the below section if you also face the same issue. Happy to help!

    1 person found this answer helpful.
    0 comments No comments