arduino-libraries / ArduinoMqttClient

ArduinoMqttClient Library for Arduino
GNU Lesser General Public License v2.1
187 stars 73 forks source link

MKR1000 mqtt example failed, error code -2 #34

Closed farellsujanto closed 4 years ago

farellsujanto commented 4 years ago

Hi, I've tried the example provided in this library, it connects well to my wifi but I cant seem to connect to the broker (I've tried google iot core and aws iot core, but none also works and return the same error). It always returns error code -2.

Board version: Arduino SAMD Boards 1.8.6 Firmware: WINC1501 Model B (19.6.1)

realonedoe commented 4 years ago

Hi

I've the same issue:

Hardware: Nano 33 IOT Nina Firmware 1.3.0

Software: ArduinoMqttClient 0.1.4 WiFiNina 1.5.0

  1. Take example "ArduinoMqttClient - WiFi Simple Sender"

  2. Use it with test.mosquitto.org Broker over port 1883 2.1 All is running fine

  3. Try it with SSL/TLS 3.1 Change port from 1883 to 8883 3.2 Change WifiClient to WifiSSLClient 3.3 Update SSL root certificate (add mosquitto.org:443) 3.3.1 I did try with test.mosquitto.org:8883 too!

The MQTT-Client returns Error -2, that means (Connection refused by server).

Thanks.

aentinger commented 4 years ago

Hi :wave: can you please provide a minimal code which demonstrates the problematic behaviour?

realonedoe commented 4 years ago

HI

Here is the Example-Code with changed objects for TLS-Connection to test.mosquitto.org:8883

Zip-File containes

Thanks.

Greetz and happy easter. Ben

Nano33IOT_MQTT_TLS.zip

aentinger commented 4 years ago

Hi. I spoke with @Rocketct who took a look at your code and he suggests to take a look at https://github.com/arduino/ArduinoCloudProviderExamples which contains examples when one wants to use TLS/SSL with MQTT.

realonedoe commented 4 years ago

Hi, thanks for clearify. Unfortunalety in our case it does not solve the problem, because my company has a own mosquitto-server and we don't wan't use any providers.

Anyway, thank you for your help, I appreciate it.

aentinger commented 4 years ago

Hi @realonedoe :wave: If you are so inclined you might try this:

aentinger commented 4 years ago

Good morning @realonedoe :wave: I'm closing this now, if you need anything else please just reopen this issue.