Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » how to increase mps in paho(I am using paho on python)
how to increase mps in paho [message #1803403] Thu, 28 February 2019 07:39 Go to next message
Darshil Shah is currently offline Darshil ShahFriend
Messages: 1
Registered: February 2019
Junior Member
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)
Re: how to increase mps in paho [message #1803613 is a reply to message #1803403] Tue, 05 March 2019 13:53 Go to previous message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 83
Registered: March 2013
Member
You are using mqtt.single() method which connects, sends a message then disconnects each time. You should use the separate connect, publish and disconnect calls, publishing without disconnecting in between.
Previous Topic:Reverse MQTT-SN transparent gateway
Next Topic:Unable to build a Project in Windows without Visual Studio
Goto Forum:
  


Current Time: Fri May 03 14:11:15 GMT 2024

Powered by FUDForum. Page generated in 0.03120 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top