Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mosquitto » Socket error on client <unknown>, disconnecting (Cannot connect to mosquitto with esp8266)
Socket error on client <unknown>, disconnecting [message #1821858] Fri, 21 February 2020 09:01
Hans Hammer is currently offline Hans HammerFriend
Messages: 1
Registered: February 2020
Junior Member
I have setup mosquitto on docker using certificates to secure the connection. I have no username and password configured in mosquitto.
I am using this code to connect my wemos d1 mini to mosquitto with pubsubclient.

https://github.com/debsahu/ESP_MQTT_Secure/blob/master/ESP8266_MQTT_SSL/Arduino/ESP8266_PubSubClient_SSL/ESP8266_PubSubClient_SSL.ino

I do not use the secrets.h file, but I tried it before with the same result.

After inserting my credentials, mqtt data and ca.crt i get the following serial output:

Attempting to connect to SSID: MYSSID ... connected! Setting time using SNTP.done! Current time: Wed Feb 19 13:53:17 2020 Time: Wed Feb 19 13:53:17 2020 MQTT connecting ... failed, status code =-2. Try again in 5 seconds. MQTT connecting ... failed, status code =-2. Try again in 5 seconds. MQTT connecting ... failed, status code =-2. Try again in 5 seconds.

mosquitto gives the following log:

1582138400: New connection from 192.168.0.8 on port 8883. 1582138405: Socket error on client <unknown>, disconnecting. 1582138405: New connection from 192.168.0.8 on port 8883. 1582138413: New connection from 192.168.0.8 on port 8883. 1582138418: Socket error on client <unknown>, disconnecting. 1582138418: New connection from 192.168.0.8 on port 8883. 1582138424: Socket error on client <unknown>, disconnecting. 1582138424: New connection from 192.168.0.8 on port 8883. 1582138429: Socket error on client <unknown>, disconnecting. 1582138429: New connection from 192.168.0.8 on port 8883. 1582138434: Socket error on client <unknown>, disconnecting. 1582138435: New connection from 192.168.0.8 on port 8883. 1582138440: Socket error on client <unknown>, disconnecting. 1582138440: New connection from 192.168.0.8 on port 8883. 1582138443: Client <unknown> has exceeded timeout, disconnecting.

At least I get the last line: disconnected because of timeout. And 192.168.0.8 is the wemos D1 mini.
I used the MQTTfx to connect to mosquitto with the ca.crt file before and it worked fine.

my mosquitto.conf:

`allow_anonymous true

port 8883

cafile /ca.crt
keyfile /server.key
certfile /server.crt
tls_version tlsv1.2

persistence true
persistence_location /mosquitto/data/
`

why does mosquitto not recognise the client name that I have specified in the code?
What is status code = -2?
Why can I not connect to mosquitto? And how can I solve this?
Previous Topic:Local/external ip's
Next Topic:"Socket error on client" when Bridge publishes topics from another Broker
Goto Forum:
  


Current Time: Thu Apr 25 17:34:29 GMT 2024

Powered by FUDForum. Page generated in 0.02622 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top