Azure / azure-iot-arduino-protocol-mqtt

Azure IoT MQTT Protocol library for Arduino
Other
25 stars 21 forks source link

MQTT send failed, not authorized #13

Closed FlorisColpaert closed 4 years ago

FlorisColpaert commented 6 years ago

Hey, I tried to send data to a device. I get the message not authorized. (I'm using the ESP32 and on Ubuntu with esp32makearduino).

Now I noticed in the error logging, the date time with your timer was incorrect. Could this be an issue? I allready runned the code with ESP-IDF and ESP32-Azure IOT. Then it works with the same connecting string. Do I have to set your time.h used library?

K.R.

Floris

-- or logger -- 2018/05/14 13:27:20 FanController Warn Fan stopped, rebooting the motor

2018/05/14 13:27:24 FlowRateCalculator Warn interpolation failed

-- your code --

Info: IoT Hub SDK for C, version 1.1.29

IoTHubClient accepted the message for delivery

Error: Time:Thu Jan 1 00:01:01 1970 File:./libs/azure-iot_arduino/src/sdk/iothubtransport_mqtt_common.c Func:mqtt_operation_complete_callback Line:1552 Connection Not Accepted: 0x5: Not Authorized

Error: Time:Thu Jan 1 00:01:02 1970 File:./libs/azure-iot_arduino/src/sdk/iothubtransport_mqtt_common.c Func:mqtt_operation_complete_callback Line:1552 Connection Not Accepted: 0x5: Not Authorized

Error: Time:Thu Jan 1 00:01:02 1970 File:./libs/azure-iot-arduino-protocol-mqtt/src/azure_umqtt_c/mqtt_client.c Func:sendPacketItem Line:332 141: Failure sending control packet data

Error: Time:Thu Jan 1 00:01:02 1970 File:./libs/azure-iot-arduino-protocol-mqtt/src/azure_umqtt_c/mqtt_client.c Func:mqtt_client_disconnect Line:1176 Error: mqtt_client_disconnect send failed

Message Id: 0 Received.

Result Call Back Called! Result is: IOTHUB_CLIENT_CONFIRMATION_BECAUSE_DESTROY

AlexeyKopchak commented 6 years ago

Hello. Have same problem, try to fix it 2 days in a row. The only thing I found out - its wrong fetched time (you can see in Thu Jan 1 00:01:01 1970). And i don't know how to fix it.

Work on Arduino 1.8.5 ESP8266 lib - 2.4.0 (very big chance problem is here) Azure lib on last version on June 13 (1.0.44).

I think if we can get correct time - we can do authorization

Do any have solution to this problem ?

FlorisColpaert commented 6 years ago

I did fix this issue by using the arduino libs to get date time of the ntp server but I should look up where in the code. This is a sub task at or company, not urgent. Try this: https://github.com/espressif/arduino-esp32/issues/935.

AlexeyKopchak commented 6 years ago

@FlorisColpaert ty for reply. I'm maybe trying ESP32, but i have ESP8266 and it will be great to find solution for it.

FlorisColpaert commented 6 years ago

@AlexeyKopchak This is also available on the esp8266 https://github.com/udif/Network-Clock/tree/master/ESP8266/GetLocalTime

AlexeyKopchak commented 6 years ago

@FlorisColpaert if it's work - where i need to put correct time on Azure mqtt lib ? I think this will not help to send correct message using MQTT to Azure IoT Hub.

AlexeyKopchak commented 6 years ago

I find solution to my problem: i change wi-fi point (i use work free wi-fi and i dont know it configuration but im trying to get it), i use android phone as router (3G) and it start work, i get correct time and my packed now valid. If i have new detail - i report here.

AlexeyKopchak commented 6 years ago

UPD. Time works only on 2.3.0 version of Arduino ESP8266 lib

anmalkov commented 5 years ago

I solved that by putting the delay(1000); after configTime(...). ESP8266 lib 2.4.2 Azure lib 1.0.45

sw-tt-chandershekharsuthar commented 5 years ago

hello @AlexeyKopchak @FlorisColpaert

I'm trying to connect ESP8266 with Azure cloud as per given Example But getting Error like " Connection Not Accepted: 0x5: Not Authorized "

Edit my wifi routers connection and "HostName=;DeviceId=;SharedAccessKey=" ArduinoIDE 1.6.5 (window10) ESP8266 lib 2.4.2 Azure lib 1.0.45

hey @anmalkov
where is that ... configTime(...). you said I solved that by putting the delay(1000); after configTime(...).

jbobotek commented 4 years ago

Issue appears resolved.