Skip to content

MKR1000 mqtt example failed, error code -2 #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
farellsujanto opened this issue Mar 31, 2020 · 7 comments
Closed

MKR1000 mqtt example failed, error code -2 #34

farellsujanto opened this issue Mar 31, 2020 · 7 comments
Labels
status: waiting for information More information must be provided before work can proceed

Comments

@farellsujanto
Copy link

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
Copy link

realonedoe commented Apr 3, 2020

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
Copy link
Contributor

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

@aentinger aentinger added the status: waiting for information More information must be provided before work can proceed label Apr 9, 2020
@realonedoe
Copy link

HI

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

Zip-File containes

  • Code without SECRETS-File for WLAN!
  • Picture "Upload certificate" over FirmwareUpdater
  • Picture with Error and opened MQTTClient.h for Error-Message

Thanks.

Greetz and happy easter.
Ben

Nano33IOT_MQTT_TLS.zip

@aentinger
Copy link
Contributor

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
Copy link

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
Copy link
Contributor

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

  • Upload your certificate into the Crypto Chip following the procedure described here.
  • Base your application on this example code.
  • Disable Server-Name-Identification (see here for further information)
-BearSSLClient sslClient(wifiClient);
+BearSSLClient sslClient(wifiClient, true);

@aentinger
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for information More information must be provided before work can proceed
Projects
None yet
Development

No branches or pull requests

3 participants