knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.81k stars 1.47k forks source link

Connection to 8883 from MKR1000 using Wifi101 not working. #135

Closed AdamMiltonBarker closed 8 years ago

AdamMiltonBarker commented 8 years ago

Hi has anyone been successful in connecting using SSL to any broker? I have issues with my own broker, Arduino and Azure IoT Hub. If it isn't possible with PubSubClient anyone know a library that can.

Thanks in advance.

knolleary commented 8 years ago

Hi @AdamMiltonBarker

this library depends on you providing a network client library for establishing the underlying TCP connection. It's at that layer that any SSL connection is negotiated - not in this library. So it isn't a question of whether this library is able to do it or not - it's all about the network library.

I have heard some have successfully used https://www.arduino.cc/en/Reference/WiFi101SSLClient to create secure connections, but I don't know if it was to Azure IoT Hub specifically.

AdamMiltonBarker commented 8 years ago

Hi thanks I am using this I just couldn't find the library again, but fails at each attempt. https://github.com/arduino/cloud-examples/blob/master/mqtt/mqtt_send_digital/mqtt_send_digital.ino

AdamMiltonBarker commented 8 years ago

I have added an issue on their repo, I will let you know if it gets resolved in case anyone else has an issue in the future.

AdamMiltonBarker commented 8 years ago

Still no reply yet from about the other library, will close this issue down and just update it when I work it out in case anyone comes over it in the future.

sandeepmistry commented 8 years ago

I've posted some updates on this here: https://github.com/arduino/cloud-examples/issues/3#issuecomment-209627682.

Just incase anyone runs into this:

1) the root cert for the Azure IoT Hub domain needs to be flashed on your board. See the WiFi101-FirmwareUpdater read me for how to do so.

2) Since the credentials for the Azure broker are super long (password alone is 138 bytes). The buffer size (MQTT_MAX_PACKET_SIZE) in this library needs to be increased, the default size 128 bytes. I successfully connected after using a buffer size of 1280 bytes (this could be lowered with some experimentation). Since I was using a SAMD based board which has 32kB of RAM, a bigger buffer is not an issue. For AVR this would not be feasible.