I have just started using MQTT.
I have installed paho on Raspberry Pi 3 B+ and on my laptop running on ubuntu 16.04.
I am trying to send data from Raspberry Pi to my laptop. I am only able to send approximately 200 messages per second. I am sending integer of len 3 or 4 as my data in each message. I am using my laptop as server i.e. I'm using localhost. And on other hand I am only able to receive 25 messages approximately on my laptop.
Someone please guide me on how I can send more messages.
I have attached the code of both publisher and subscriber.
Publisher Code:
import paho.mqtt.publish as mqtt
import time
import serial
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)
time.sleep(2)
a = time.time()
num = 0
while (time.time() - a) < 1.0:
try:
data = int(ser.readline())
mqtt.single("test", data, hostname="10.42.0.1")
num = num + 1
except ValueError:
None
print(num)
ser.close()
Subscriber code:
import paho.mqtt.subscribe as mqtt
import time
b=0
a = time.time()
while True:
msg = mqtt.simple("0", hostname="10.42.0.1")
b=b+1
print(msg.payload, b)