knolleary / pubsubclient

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

Error Status Code -2 #594

Open aaronmcniven opened 5 years ago

aaronmcniven commented 5 years ago

Hi guys,

I'm having trouble connecting to a Mosquitto broker I'm hosting on my LAN. I've set it up and made it secure and I've been connecting to it via TLS V1.2 with a Windows program and it hasn't had any troubles. I also tested it with an ESP8266 with security disabled and it has been fine.

Basically when I try to connect to it with my ESP32 (using the same root CA I'm using on the Windows client that works) it will fail to connect, with client.state() = -2.

At the same time, within the Broker log file, I get this:

New connection from 10.55.10.202 on port 8883. OpenSSL Error: error:14094412:SSL routines:ssl3_read_bytes:sslv3 alert bad certificate Socket error on client , disconnecting.

And that is as far as I've gotten. I've tried tricks I've found here, such as setting the AP mode (WIFI_STA) before connecting the WiFi, and setting a static local IP, DNS, etc, with no luck. I can't fault the CA file. I've tried messing with the formatting, adding \r\n instead of just \n. Triple checking each line of the CA, etc.

Sorry for the messy code, I'm just trying to get it working for now, but I've changed it that much trying to figure this out it's a little messy.

Here's my INO: https://paste.debian.net/1075186/ Here's my mosquitto.conf: https://paste.debian.net/1075187/

If there's any ideas I can try that would be great. Thank you. :)

aaronmcniven commented 5 years ago

I was using the wrong board type in the Arduino IDE. Problem solved. I purchased ESP-WROOM-32U units from eBay. That board wasn't available in the Arduino IDE and I was trying to use the ESP32 WROVER Module.

Selecting ESP32 Pico Kit from the boards menu fixed it.