Reputation: 31
Running mosquito broker in docker, broker ip address is 172.18.5.10, docker network gateway is 172.18.5.1. There are also some other dockers attached to that network, also I do have several MQTT devices / programs subscribed and publishing to Mosquito broker and working just fine.
The issues is I am getting following error every ~ 40 seconds.
2023/02/22T14:20:09: New connection from 172.18.5.1:47008 on port 1883.
2023/02/22T14:20:09: Client <unknown> disconnected due to malformed packet.
2023/02/22T14:20:37: New connection from 172.18.5.1:47162 on port 1883.
2023/02/22T14:20:37: Client <unknown> disconnected due to malformed packet.
2023/02/22T14:21:05: New connection from 172.18.5.1:47270 on port 1883.
2023/02/22T14:21:05: Client <unknown> disconnected due to malformed packet.
2023/02/22T14:21:33: New connection from 172.18.5.1:47418 on port 1883.
2023/02/22T14:21:33: Client <unknown> disconnected due to malformed packet.
2023/02/22T14:22:01: New connection from 172.18.5.1:47538 on port 1883.
2023/02/22T14:22:01: Client <unknown> disconnected due to malformed packet.
2023/02/22T14:22:29: New connection from 172.18.5.1:47674 on port 1883.
2023/02/22T14:22:29: Client <unknown> disconnected due to malformed packet.
2023/02/22T14:22:57: New connection from 172.18.5.1:47782 on port 1883.
Here is result from wireshark for
2023/02/22T14:21:05: New connection from 172.18.5.1:47270 on port 1883.
2023/02/22T14:21:05: Client <unknown> disconnected due to malformed packet.
More detailed error image for different src port
Here is an example of good and bad connections, good connection are from local IP address range but this malformed is always from network gateway:
2023/02/21T22:38:03: New client connected from 192.168.3.8:52207 as sw-tasmota-hall (p2, c1, k30, u'data').
2023/02/21T22:38:04: New connection from 192.168.3.1:57113 on port 1883.
2023/02/21T22:38:04: New client connected from 192.168.3.1:57113 as switch-tasmota-bath (p2, c1, k30, u'data').
2023/02/21T22:38:04: New connection from 192.168.2.4:58631 on port 1883.
2023/02/21T22:38:04: New client connected from 192.168.2.4:58631 as node-tasmota-garage (p2, c1, k30, u'data').
2023/02/21T22:38:06: New connection from 172.18.5.1:48908 on port 1883.
2023/02/21T22:38:06: Client <unknown> disconnected due to malformed packet.
2023/02/21T22:38:28: New connection from 172.18.5.1:49018 on port 1883.
2023/02/21T22:38:28: Client <unknown> disconnected due to malformed packet.
2023/02/21T22:38:50: New connection from 172.18.5.1:49160 on port 1883.
2023/02/21T22:38:50: Client <unknown> disconnected due to malformed packet.
Docker-compose:
version: '3'
services:
mosquitto:
image: eclipse-mosquitto:2.0.15
container_name: mosquitto
restart: unless-stopped
environment:
- TZ=Europe/Prague
ports:
- "1883:1883"
volumes:
- /share/Container/mosquitto/data:/mosquitto/data
- /share/Container/mosquitto/config:/mosquitto/config
- /share/Container/mosquitto/log:/mosquitto/log
- /etc/localtime:/etc/localtime:ro
logging:
driver: "syslog"
options:
syslog-address: "tcp://192.168.1.106:514"
tag: "{{.Name}}/{{.ImageName}}"
networks:
ha_net:
ipv4_address: 172.18.5.10
networks:
ha_net:
external: true
mosquitto.conf
persistence true
persistence_location /mosquitto/data/
persistence_file mosquitto.db
listener 1883
allow_anonymous true
log_type error
log_type warning
log_type notice
log_type information
log_dest stdout
log_timestamp true
log_timestamp_format %Y/%m/%dT%H:%M:%S
password_file /mosquitto/config/pwfile
I am looking for help how to detect ip address of the device/host/program that is causing this issue.
Thanks, salvq
Upvotes: 0
Views: 1318
Reputation: 11
I am having the same issue but the case happens on esp32 with pubsubclient. the main problem is caused by my device has same id connected to broker on multiple devices. make sure every connection that you generate has a unique id.
Upvotes: 0
Reputation: 31
I was able to fix the issue (disconnects due to malformed packet) by running mosquito docker in HOST network mode rather than custom bridge network mode.
However, I have not been able to determine the root cause of the disconnects due to malformed packet on the docker custom bridge network, but not in host network mode.
Working docker-compose
version: '3'
services:
mosquitto:
image: eclipse-mosquitto:2.0.15
container_name: mosquitto
restart: unless-stopped
network_mode: host
environment:
- TZ=Europe/Prague
volumes:
- /share/Container/mosquitto/data:/mosquitto/data
- /share/Container/mosquitto/config:/mosquitto/config
- /share/Container/mosquitto/log:/mosquitto/log
- /etc/localtime:/etc/localtime:ro
logging:
driver: "syslog"
options:
syslog-address: "tcp://192.168.1.106:514"
tag: "{{.Name}}/{{.ImageName}}"
Upvotes: 0