MQTT : Broker C005 connection failed

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
tparvais
Normal user
Posts: 99
Joined: 28 Oct 2015, 23:13

MQTT : Broker C005 connection failed

#1 Post by tparvais » 04 Aug 2020, 19:19

Hello

I've issue with one of my Remote Wemos connected to my Mosquitto server via internet:

Wemos -- Internet box A -- internet -- Internet box B -- Mosquitto_Server

I open properly 1883 TCP port on Box B (online check is ok) to forward MQTT traffic to mosquitto

On Wemos, I got the following log:
1661730091: MQTT : Intentional reconnect
1661730631: MQTT : Broker C005 connection failed (180415/0)
1661738216: MQTT : Intentional reconnect
1661738353: MQTT : Broker C005 connection failed (180416/0)

Wemos details:

Code: Select all

Unit Number:	0
Local Time:	2020-08-04 19:08:38
Uptime:	19 days 5 hours 43 minutes
Load:	18.57% (LC=2643)
CPU Eco Mode:	false
Free RAM:	15168 (34568 - )
Free Stack:	3664 (3824 - )
Heap Max Free Block:	14440
Heap Fragmentation:	5%
Boot:	Cold boot (0)
Reset Reason:	External System
Last Task:	Background Task
SW WD count:	0
Network ❔
Wifi:	802.11N (RSSI -83 dB)
IP Config:	Static
IP / Subnet:	192.168.1.9 / 255.255.255.0
Gateway:	192.168.1.1
Client IP:	192.168.1.8
DNS:	1.1.1.1 / (IP unset)
Allowed IP Range:	192.168.1.0 - 192.168.1.255
STA MAC:	D8:BF:C0:C7:59:C2
AP MAC:	DA:BF:C0:C7:59:C2
SSID:	ARBA-NEIGE (30:7C:B2:82:4D:86)
Channel:	6
Connected:	15d21h11m
Last Disconnect Reason:	(2) Auth expire
Number Reconnects:	2
WiFi Settings
Force WiFi B/G:	false
Restart WiFi Lost Conn:	false
Force WiFi No Sleep:	false
Periodical send Gratuitous ARP:	false
Connection Failure Threshold:	0
Firmware
Build:⋄	20108 - Mega
System Libraries:⋄	ESP82xx Core a5432625, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support
Git Build:⋄	mega-20200703
Plugin Count:⋄	46 [Normal]
Build Origin:	Travis
Build Time:⋄	Jul 3 2020 11:44:07
Binary Filename:⋄	ESP_Easy_mega_20200703_normal_ESP8266_4M1M
Build Platform:⋄	Linux-5.0.0-1031-gcp-x86_64-with-glibc2.2.5
Git HEAD:⋄	HEAD
System Status
Syslog Log Level:	None
Serial Log Level:	Info
Web Log Level:	None
ESP Board
ESP Chip ID:	13064642 (0xC759C2)
ESP Chip Frequency:	80 MHz
ESP Board Name:	PLATFORMIO_ESP12E
Storage
Flash Chip ID:	Vendor: 0x68 Device: 0x4016
Flash Chip Real Size:	4096 kB
Flash IDE Size:	4096 kB
Flash IDE Speed:	40 MHz
Flash IDE Mode:	DIO
Flash Writes:	23 daily / 110 boot
Sketch Size:	842 kB (2228 kB free)
Max. OTA Sketch Size:	1019 kB (1044464 bytes)
OTA possible:	true
OTA 2-step Needed:	false
SPIFFS Size:	934 kB (844 kB free)
Page size:	256
Block size:	8192
Number of blocks:	116
Maximum open files:	5
Maximum path length:	32
devices configured on Wemos:

Code: Select all

1	✔	Environment - DS18b20	Frigo_3	28-d9-d0-61-1-0-0-a6	

❶
	GPIO-5	
Temperature:
19.06
Edit	2	✔	Environment - DS18b20	Frigo_2	28-1b-81-c7-1-0-0-af	

❶
	GPIO-5	
Temperature:
19.50
Edit	3	✔	Environment - DS18b20	Frigo_1	28-97-e6-5e-1-0-0-a	

❶
	GPIO-5	
Temperature:
17.06
Edit	4	✔	Environment - DS18b20	Congélateur_1	28-8f-ba-79-a2-0-3-42	

❶
	GPIO-5	
Temperature:
-11.69
Edit	5	✔	Environment - DS18b20	Temp_exterieure	28-73-e7-61-1-0-0-e0	

❶
	GPIO-13	
Temperature:
16.19
Edit	6	✔	Environment - DS18b20	Chaudière_Sortie	28-32-de-61-1-0-0-d5	

❶
	GPIO-13	
Temperature:
20.69
Edit	7	✔	Environment - DS18b20	Congélateur_Bahut	28-7-c-79-a2-0-3-da	

❶
	GPIO-12	
Temperature:
-36.88
Edit	8	✔	Environment - DS18b20	Congélateur_2	28-e1-c1-79-a2-0-3-8f	

❶
	GPIO-14	
Temperature:
18.69
Add	9							
Add	10							
Add	11							
Edit	12	✔	Generic - System Info	SysInfo		

❶
		
uptime:
27712.00
rssi:
-89.00
load:
19.84
:
0.00


on mosquitto, I see the following log:

1596560608: New connection from 2.7.250.177 on port 1883.
1596560608: Sending CONNACK to 2.7.250.177 (0, 5)
1596560609: New connection from 2.7.250.177 on port 1883.
1596560609: Sending CONNACK to 2.7.250.177 (0, 5)
1596560609: New connection from 2.7.250.177 on port 1883.
1596560609: Sending CONNACK to 2.7.250.177 (0, 5)
1596560619: New connection from 2.7.250.177 on port 1883.
...

mosquitto.conf:

Code: Select all

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
password_file /mosquitto/config/mosquitto.passwd
allow_anonymous true

log_type all
but not more, not others details published in the log, seems to not receive any real publication from the wemos.

I don't have this problem with others Wemos using older build and MQTT.

any idea ?

tparvais
Normal user
Posts: 99
Joined: 28 Oct 2015, 23:13

Re: MQTT : Broker C005 connection failed

#2 Post by tparvais » 04 Aug 2020, 19:50

I keep my analysis by doing a Wireshark.

I see the Wemos is properly sending the connect command with proper username/password

Connect Flags: 0xc0, User Name Flag, Password Flag, QoS Level: At most once delivery (Fire and Forget)

with right username and password as defined in mosquitto.passwf (then hashed with proper command)

next packet is : Return Code: Connection Refused: not authorized (5)by mosquitto

and no specific log in mosquitto.log

tparvais
Normal user
Posts: 99
Joined: 28 Oct 2015, 23:13

Re: MQTT : Broker C005 connection failed

#3 Post by tparvais » 04 Aug 2020, 21:44

Self answer: i found the problem

mosquitto passwd file does not accept 2 different user names, very strangely....
it uses only the first top name of the file

pitchout
Normal user
Posts: 34
Joined: 13 Oct 2021, 19:57

Re: MQTT : Broker C005 connection failed

#4 Post by pitchout » 07 Jan 2023, 15:45

Hello community,
Above all, a very happy new year 2023 to all, hoping that it brings us a positive evolution from all points of view.
I turn to you because for some time, I have had a problem with my esp under espeasy. They are associated with a broker on rpi4 / Jeedom.
Very regularly, every 2 minutes... the broker is disconnected and reconnects on its own, but it very much hinders its use.
I haven't changed anything except recently I changed my internet box and the WIfi network but on this side I don't see anything abnormal. There's only one who does that, the others don't... (at least 5 in the house). What could be the reasons? An idea ?
Thank you.

Image
Attachments
322739590_658226979430747_849758988656048733_n.jpg
322739590_658226979430747_849758988656048733_n.jpg (102.72 KiB) Viewed 2600 times
Last edited by pitchout on 07 Jan 2023, 16:05, edited 1 time in total.

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT : Broker C005 connection failed

#5 Post by TD-er » 07 Jan 2023, 15:47

Can you check on the sysinfo page to see what the reported DNS server IP is?
If this differs from what you'd expect, then I just merged the fix for you :)

pitchout
Normal user
Posts: 34
Joined: 13 Oct 2021, 19:57

Re: MQTT : Broker C005 connection failed

#6 Post by pitchout » 07 Jan 2023, 16:08

This is my two esp and the config is the same !

2023-01-07_16-06-55.png
2023-01-07_16-06-55.png (53.18 KiB) Viewed 2589 times
2023-01-07_16-07-02.png
2023-01-07_16-07-02.png (52.06 KiB) Viewed 2589 times
thank you

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT : Broker C005 connection failed

#7 Post by TD-er » 07 Jan 2023, 17:35

How often does this disconnect from the MQTT broker happen?
To me it doesn't seem so odd when the ESP needs to reconnect to the broker every now and then.
As soon as it becomes a continuous retry, then it is for sure an incredible hit on performance.

There is a number of reasons the connection to the broker is reset:
- Broker disconnects client when it receives a malformed packet (e.g. claimed size differs from actual size)
- Client timeout is too short (e.g. default of 100 msec may be too short when the broker is running on less powerful hardware or not in the local network)
- WiFi connection is not stable (e.g. packet loss may also trigger above reasons)

Also, what build are you running?

Post Reply

Who is online

Users browsing this forum: No registered users and 55 guests