eclipse / paho.mqtt.python

paho.mqtt.python
Other
2.17k stars 723 forks source link

`bind_address` not working #664

Open geoffbrucepayne opened 2 years ago

geoffbrucepayne commented 2 years ago

I am running on a Raspberry Pi with multiple network interfaces, and need to exclusively use one of those interfaces for the MQTT client. When I specify bind_addess='192.168.128.102' (eth2) in my client.connect() call, the connection is still being initiated on another address/interface 192.168.1.129 (eth0) which I confirmed by wireshark trace. Am I doing something wrong or is there a better way to force a specific interface?

almex-m-bulbul commented 1 year ago

facing same issue.

MattBrittan commented 8 months ago

I've tested this on my machine (windows - client.connect("mqtt.eclipseprojects.io", 1883, 60, bind_address="192.168.168.240", bind_port=0) and it appeared to work as designed (switching to another interface address resulted in a change to the source IP shown in wireshark).

Can you please provide more information (ideally a minimal, reproducible example along with a description of your network configuration and OS info). Before doing this you might find this answer on stack overflow of interest...