kelster101757
Posts: 10
Joined: Fri Mar 24, 2017 11:43 am

MQTT works on windows but not from a pi using same script??

Mon Aug 12, 2019 5:07 pm

Hello,

When i connect to a newly installed mosquitto client from my windows machine it works fine

Code: Select all

>>> import paho.mqtt.client as mqtt #import the client1
>>> broker_address="172.16.24.107"
>>> #broker_address="iot.eclipse.org" #use external broker
... client = mqtt.Client("ppppp") #create new instance
>>> client.connect(broker_address) #connect to broker
0
>>> client.publish("house/main-light","OFF")#publish
<paho.mqtt.client.MQTTMessageInfo object at 0x03B18570>
When i connect on my raspberry pi it sticks on connecting to broker as shown below.

Raspberry pi

Code: Select all

>>> import paho.mqtt.client as mqtt #import the client1
>>> broker_address="172.16.24.107"
>>> #broker_address="iot.eclipse.org" #use external broker
... client = mqtt.Client("ppppp") #create new instance
>>> client.connect(broker_address) #connect to broker

Any ideas on how to resolve this? I dont understand why windows can connect fine but linux cant. The linux box can connect to another mqtt server fine and thats running version mosquitto version 1.4.10.

server information :

The new mosiquotto broker is using version 1.5.7.

Windows information :

[*]Python 3.7.0 version
[*]paho-mqtt==1.4.0

Linux (pi)

[*]Python 3.5.3
paho-mqtt==1.4.0


The mosquitto log file seams to be reporting a lot of lines :

1565628769: New client connected from 192.34.98.117 as ppppp (c1, k60).
1565628861: Client ppppp has exceeded timeout, disconnecting.

voltzeps
Posts: 7
Joined: Wed Jul 11, 2018 5:05 pm

Re: MQTT works on windows but not from a pi using same script??

Thu Aug 15, 2019 1:01 am

Try

Code: Select all

client.loop_start()
at the end of your configuration

Return to “Python”