firedog1024 / mkr1000-iotc

Connecting an Arduino MKR1000 to Azure IoT Central
MIT License
32 stars 14 forks source link

mqtt failed, rc=-2 on MKR1010 #10

Open 4lenz1 opened 4 years ago

4lenz1 commented 4 years ago

Hi thanks for the amazing guideline I've read #2 and #3 but still facing rc=-2 problem as below

16:48:04.885 -> Getting the time from time service: 16:48:04.920 -> Current time: 29. August 2020 - Saturday 07:48:05 16:48:04.955 -> Getting IoT Hub host from Azure IoT DPS 16:48:15.020 -> Starting IoT Hub connection 16:48:25.205 -> ---> mqtt failed, rc=-2 16:48:37.233 -> ---> mqtt failed, rc=-2 16:48:49.262 -> ---> mqtt failed, rc=-2 16:49:01.284 -> ---> mqtt failed, rc=-2 . . .

And I did not get couldn't connect to DPS error message like this post , anyone know how should I fix this problem ?

ehenneberg commented 4 years ago

Hi , thanks for the suggestions in #2 and #3 , they worked for me, except iotc_scopeId is name for oithubHost in configure.h .

So at line# 316 in mkr10x0iotc.ino I commented out these 3 lines and added iothubHost = iotc_scopeId;

// char hostName[64] = {0};
// getHubHostName((char*)iotc_scopeId, (char*)iotc_deviceId, (char*)iotc_deviceKey, hostName);
// iothubHost = hostName;
iothubHost = iotc_scopeId;