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

MQTT connection failed #950

Open Cyanid12 opened 2 years ago

Cyanid12 commented 2 years ago

Hi, I have had a working system with a Raspberry Pi ( Node Red) and a ESp32 communicating over MQTT. Installed on the Pi is Mosquitto. 2 Days ago I did some rewiring and took out the switches for my Room. When I put them back in and Power was back, the MQTT Broker seemed to have connecting problems. I checked the IP Adress of the Pi and it is still the same as it was before. I'm no Linux expert, so I don't know what to do because everything used to work perfectly... I even reinstalled the IMG file and the "Server" Setup but it doesen't work. Node_Red can still acsess Databases etc. on the Pie so the only thing which isn't working is MQTT. I tried to restart mosquitto but it didn't help. Does anyone have a clue what might be wrong there? Im wondering if it might have something to do with starting in local only mode since the tutorial I watched hasn't had this message.

pi@raspberrypi:~ $ 1654278607: mosquitto version 2.0.11 starting 1654278607: Using default config. 1654278607: Starting in local only mode. Connections will only be possible from clients running on this machine. 1654278607: Create a configuration file which defines a listener to allow remote access. 1654278607: For more details see https://mosquitto.org/documentation/authentication-methods/ 1654278607: Opening ipv4 listen socket on port 1883. 1654278607: Error: Address already in use 1654278607: Opening ipv6 listen socket on port 1883. 1654278607: Error: Address already in use

sudo /bin/systemctl status mosquitto.service ● mosquitto.service - Mosquitto MQTT Broker Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2022-06-03 19:33:04 CEST; 23min ago Docs: man:mosquitto.conf(5) man:mosquitto(8) Process: 1102 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS) Process: 1103 ExecStartPre=/bin/chown mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS) Process: 1104 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS) Process: 1105 ExecStartPre=/bin/chown mosquitto /run/mosquitto (code=exited, status=0/SUCCESS) Main PID: 1106 (mosquitto) Tasks: 1 (limit: 1598) CPU: 728ms CGroup: /system.slice/mosquitto.service └─1106 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Jun 03 19:33:04 raspberrypi systemd[1]: Starting Mosquitto MQTT Broker... Jun 03 19:33:04 raspberrypi systemd[1]: Started Mosquitto MQTT Broker.

I did read related problems many seem to have problems after restarting broker or power loss but haven't figured a solution yet, hop you can help me out

thanks

aujincheng commented 2 years ago

Maybe can try with: net stop mosquitto then net start mosquitto