I'm running an MQTT Broker on my Windows machine using Mosquitto broker. I have setup a client on the same Windows machine through the Paho MQTT python library. Another client is setup using the same python library on a Linux machine that I have.
So, when I publish a file from the Windows client, it reaches the Linux client easily without any issues. However, when I tried to publish a file from my Linux client, it does not reach my Windows client. Later I noticed that if the file size is greater than 50KB, the file does not transfer from the linux machine. The log from the broker does not display the "Publish message recieved" if the filesize exceeds 50KB.
The code for Windows machine to publish:
import paho.mqtt.client as mqtt
import time
client = mqtt.Client("P2")
client.on_message=on_message
print("COnnecting")
client.connect("localhost")
print("Connected")
f = open("D:/Downloads/test.txt",'rb')
imagestring = f.read()
byteArray = bytearray(imagestring)
print("Publishing")
client.publish("photo", byteArray)
The code for Linux machine to subscribe:
import paho.mqtt.client as mqtt
import time
def on_message(mosq, obj, msg):
with open('test.txt', 'wb') as fd:
fd.write(msg.payload)
print("message topic=",msg.topic)
client = mqtt.Client("P1")
client.on_message=on_message
print("COnnecting")
client.connect("192.168.1.115")
client.loop_start()
print("Subbing")
client.subscribe("photo")
time.sleep(1000)
client.loop_stop()
Code for Windows machine to subscribe:
import paho.mqtt.client as mqtt
import time
def on_message(mosq, obj, msg):
with open('test.txt', 'wb') as fd:
fd.write(msg.payload)
print("message topic=",msg.topic)
client = mqtt.Client("P2")
client.on_message=on_message
print("COnnecting")
client.connect("localhost")
client.loop_start()
print("Subbing")
client.subscribe("photo")
time.sleep(1000)
client.loop_stop()
Code for Linux machine to publish:
import paho.mqtt.client as mqtt
import time
client = mqtt.Client("P1")
print("COnnecting")
client.connect("192.168.1.115")
print("Connected")
f = open("/opt/plcnext/test.txt","rb")
imagestring = f.read()
byteArray = bytearray(imagestring)
print("Publishing")
client.publish("photo", byteArray)
Is there any restriction from the Linux machine side? or am I doing something wrong here?