mattmiller
Posts: 1907
Joined: Thu Feb 05, 2015 11:25 pm

Re: MQTT Python paho library for IoT

Sat Oct 08, 2016 10:43 pm

Yipee!!! :)

I was starting mosquitto from terminal (not as service) and it turns out you have to use

Code: Select all

mosquitto -c /etc/mosquitto/mosquitto.conf
to get it to read the conf file
(Its always the little things that bite you in the backside)
0.png
0.png (10.81 KiB) Viewed 1409 times
Thanks for persevering with me Dougie :)

asandford
Posts: 1999
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: MQTT Python paho library for IoT

Sat Oct 08, 2016 10:51 pm

mattmiller wrote: Well thats the name I was giving to the web page that interfaces to the stuff going on behind it
Seemed a reasonable description to me :)
That's the 'IDE' for developing flows, not really useful for interaction.

I originally wrote the greenhouse automation in python, but as I added more sensors and actuators, it became a nightmare (each sensor had its own sub-process) and was difficult to see what it was up to (I added MQ messages just to let me know). I also wanted to record all the values in a DB.

I rewrote it all into NR a few years ago and have never looked back.

mattmiller
Posts: 1907
Joined: Thu Feb 05, 2015 11:25 pm

Re: MQTT Python paho library for IoT

Sat Oct 08, 2016 10:55 pm

That's the 'IDE'
You say IDE - I say interface :)

But since my original point was that it is no good for users - so at least we are agreed on that :)

User avatar
DougieLawson
Posts: 33362
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: MQTT Python paho library for IoT

Sat Oct 08, 2016 11:13 pm

Now run mosquitto_pub -t "test_topic" -m "Test payload for test_topic"

Then you can start coding your websockets dashboard.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

asandford
Posts: 1999
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: MQTT Python paho library for IoT

Sat Oct 08, 2016 11:14 pm

mattmiller wrote:
That's the 'IDE'
You say IDE - I say interface :)

But since my original point was that it is no good for users - so at least we are agreed on that :)
That's like saying IDLE or Eclipse or Netbeans is no good for users; it's not for users it's for developers.

You can create an interface with whatever takes your fancy, from LEDs and buttons on the Pi, a fully interactive web page, or even an app on your phone.

This has been discussed many times before, and MQTT for IOT marry very well with NR (both MQTT and NR are IBM projects).

mattmiller
Posts: 1907
Joined: Thu Feb 05, 2015 11:25 pm

Re: MQTT Python paho library for IoT

Sat Oct 08, 2016 11:23 pm

@asandford
This is how I see things
I was asking for help to get websockets working
You came along and said use NodeRED
I said NodeRED is great for geeks but i wanted websockets to make a webpage for users (rest of my household)

We've then got into some other argument about things that don't matter

Can we stop please so I can get back on with the websocket stuff? :)

mattmiller
Posts: 1907
Joined: Thu Feb 05, 2015 11:25 pm

Re: MQTT Python paho library for IoT

Sat Oct 08, 2016 11:28 pm

Now I understand the flow of what is going on with the websockets - I realise I don't need apache2 to serve a little webpage

So I've disabled it and simply used

Code: Select all

cd /var/www/html
sudo python -m SimpleHTTPServer 80
to do the same job

But then as I type this , I'll prob go back to using apache2 (as it runs as a service and so will be enabled automatically at boot so ideal for coping with mains failures- one less job to sort)

asandford
Posts: 1999
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: MQTT Python paho library for IoT

Sat Oct 08, 2016 11:30 pm

mattmiller wrote:@asandford
This is how I see things
I was asking for help to get websockets working
You came along and said use NodeRED
I said NodeRED is great for geeks but i wanted websockets to make a webpage for users (rest of my household)

We've then got into some other argument about things that don't matter

Can we stop please so I can get back on with the websocket stuff? :)
Fine.

User avatar
DougieLawson
Posts: 33362
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: MQTT Python paho library for IoT

Sun Oct 09, 2016 11:02 am

mattmiller wrote: But then as I type this , I'll prob go back to using apache2 (as it runs as a service and so will be enabled automatically at boot so ideal for coping with mains failures- one less job to sort)
Both Lighty and Nginx run as a service. Try either of those, they have a lower footprint than Apache2.

My Raspberries run the following

Code: Select all

******** Apollo ==> Server: Apache/2.4.10 (Raspbian)
******** Challenger ==> Server: Apache/2.4.10 (Raspbian)
******** Beaufort ==> Server: Apache/2.4.10 (Raspbian)
******** Eagle ==> Server: lighttpd/1.4.35
******** Pi ==> Server: lighttpd/1.4.35
******** Raspberry ==> Server: nginx/1.6.2
******** Raspberrypi ==> Server: Apache/2.2.22 (Debian)
******** Saturn ==> Server: lighttpd/1.4.35
******** Odyssey ==> Server: lighttpd/1.4.35
******** Falcon ==> Server: nginx/1.6.2
******** Aplus ==> Server: nginx/1.6.2
four Apaches, four Lightys, three Nginxs
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

mattmiller
Posts: 1907
Joined: Thu Feb 05, 2015 11:25 pm

Re: MQTT Python paho library for IoT

Sun Oct 09, 2016 8:11 pm

Ta
Giving lighttpd a go :)

wanstreet
Posts: 38
Joined: Fri Jun 01, 2018 5:28 am

Re: MQTT Python paho library for IoT

Wed Jul 11, 2018 8:12 am

DougieLawson wrote:
Sat Oct 08, 2016 7:49 am
OK. So we can update the config file for that. Create a new file /etc/mosquitto/conf.d/ws.conf

Code: Select all

port 1883
protocol mqtt
listener 8883
protocol mqtt

listener 9001
protocol websockets
then grab a copy of https://github.com/jpmens/simple-mqtt-w ... master.zip and unzip it to /var/www/somedirectorygoeshere so you can access it with your web server.
Can I open multiple ports based on this configuration ?
like

Code: Select all

port 1883
protocol mqtt 
port 1884
protocol mqtt
I was looking around on how to increase the speed of mqtt communication and thought of maybe a single port communication be the issue.

mattmiller
Posts: 1907
Joined: Thu Feb 05, 2015 11:25 pm

Re: MQTT Python paho library for IoT

Wed Jul 11, 2018 9:35 pm

I was looking around on how to increase the speed of mqtt communication and thought of maybe a single port communication be the issue.
I don't think trying to aggregate ports is going to help (much)

At the end of the day, MQTT is normally sent as TCP/IP packets with some overhead bytes to handle message relability

So, speed depends upon the speed of your link and how fast the brokers/clients respond to messages

I don't know how much delay a mosquitto (for instance) broker adds to things but I'd imagine that its quite effecient

The quick way to improve speed probably would come from using a dedicated broker on a dedicated machine

You might get a speed increase if you wrote your own dedicated broker that didn't implement unneeded features in the MQTT 3.11 spec and only passed msgs between clients without any security or handled > QOS 1 or LWT type stuff

wanstreet
Posts: 38
Joined: Fri Jun 01, 2018 5:28 am

Re: MQTT Python paho library for IoT

Thu Jul 12, 2018 7:58 am

mattmiller wrote:
Wed Jul 11, 2018 9:35 pm
I was looking around on how to increase the speed of mqtt communication and thought of maybe a single port communication be the issue.
I don't think trying to aggregate ports is going to help (much)

At the end of the day, MQTT is normally sent as TCP/IP packets with some overhead bytes to handle message relability

So, speed depends upon the speed of your link and how fast the brokers/clients respond to messages

I don't know how much delay a mosquitto (for instance) broker adds to things but I'd imagine that its quite effecient

The quick way to improve speed probably would come from using a dedicated broker on a dedicated machine

You might get a speed increase if you wrote your own dedicated broker that didn't implement unneeded features in the MQTT 3.11 spec and only passed msgs between clients without any security or handled > QOS 1 or LWT type stuff
The thing is I need the security for the messages, since its a tcp based communication, i dont need the extra qos features.
What I was thinking is that , if I can have 2 ports , 1 for listening and 1 for replying, then I can reduce the overload on the 1883 and increase the message communication a little bit more.

DirkS
Posts: 8501
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: MQTT Python paho library for IoT

Thu Jul 12, 2018 8:04 am

wanstreet wrote:
Thu Jul 12, 2018 7:58 am
What I was thinking is that , if I can have 2 ports , 1 for listening and 1 for replying, then I can reduce the overload on the 1883 and increase the message communication a little bit more.
Are you sure communication needs speeding up?
Have you actually done some testing?

wanstreet
Posts: 38
Joined: Fri Jun 01, 2018 5:28 am

Re: MQTT Python paho library for IoT

Thu Jul 12, 2018 2:03 pm

DirkS wrote:
Thu Jul 12, 2018 8:04 am
wanstreet wrote:
Thu Jul 12, 2018 7:58 am
What I was thinking is that , if I can have 2 ports , 1 for listening and 1 for replying, then I can reduce the overload on the 1883 and increase the message communication a little bit more.
Are you sure communication needs speeding up?
Have you actually done some testing?
Not with bulk data, sorry, dat was just a theory.
I am working with it, continuous data from 4 devices will be streamed, so i was looking for improving the speed beforehand, basic testing with small dummy data is working great, no issues with that,
So.

Return to “Python”

Who is online

Users browsing this forum: No registered users and 12 guests