mqtt and Apache and mod_websocket_mosquitto

Forum about MQTT, machine-to-machine (M2M), "Internet of Things" and Node.js

Moderators: Digit, Rene, Willem4ever, Bwired

mqtt and Apache and mod_websocket_mosquitto

Postby Kroonen » Wed Feb 19, 2014 9:46 pm

Hi,

After thinking about node.js I also want to try apache with mosquito.

I followed the instructions and compiled from willems github site

https://github.com/willem4ever/mod_websocket_mosquitto

Everything compiled ok and I can enable the module.

But how can I check if it works? I don't know how to write a simple html as subscriber to display the messages. I use the matt.html, but gives nothing

http://www.kroonen.eu/mqtt/mosq.html

Any idea where I can check things and to configure in html

regards Richard
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Kroonen » Wed Feb 19, 2014 9:58 pm

Hi,

I can connect, but no messages receive and after a short who I get this socket read error, any ideas

root@fitpc2:/var/www/mqtt# mosquitto
1392843363: Warning: Mosquitto should not be run as root/administrator.
1392843363: mosquitto version 0.15 (build date 2012-12-29 18:54:18+0000) starting
1392843363: Opening ipv4 listen socket on port 1883.
1392843363: Opening ipv6 listen socket on port 1883.
1392843368: New connection from 127.0.0.1.
1392843368: New client connected from 127.0.0.1 as mjsws/bJjY2KolxGTwlX.
1392843380: New connection from 127.0.0.1.
1392843380: New client connected from 127.0.0.1 as mosq_pub_4194_fitpc2.
1392843388: Socket read error on client mjsws/bJjY2KolxGTwlX, disconnecting.
1392843393: New connection from 127.0.0.1.
1392843393: New client connected from 127.0.0.1 as mjsws/SclqIi2HtMCEVG.
1392843395: New connection from 127.0.0.1.
1392843395: New client connected from 127.0.0.1 as mjsws/IdZ2UNUtq6aEnO.
1392843406: Socket read error on client mjsws/IdZ2UNUtq6aEnO, disconnecting.
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Kroonen » Wed Feb 19, 2014 10:08 pm

It looks like the mosq.html is not fine.

If someone has a small html code how to have a subscribed something so I can use it.

regards Richard
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Digit » Wed Feb 19, 2014 11:04 pm

Have you checked the Apache logs, any strange messages in there?
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Kroonen » Thu Feb 20, 2014 10:03 am

Robert

No errrors in log from apache.

Have youj som html code to test?

regards Richard
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Bwired » Thu Feb 20, 2014 12:28 pm

We are not using apache as a webserver, i think Willem is the only one, but not sure.....
User avatar
Bwired
Administrator
Administrator
 
Posts: 5304
Joined: March 2006
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Digit » Thu Feb 20, 2014 7:56 pm

Richard,

Even better, a live example: :wink:
http://www.hekkers.net/domotica/Smartmeter.aspx

The interesting part for you starts at line 324 (view source).
This example works with Apache and Willem's module.
If you need more info just let me know.
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Kroonen » Fri Feb 21, 2014 11:16 am

Hi,

Thnx for the code.

I still gets disconnected, the browser session is disconnected with socket error after in exact 60 sec.

So it looks like a timer somewhere?

http://www.kroonen.eu/temp/meter.html

Richard
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby RDNZL » Fri Feb 21, 2014 7:47 pm

If you use Apache, try this:
Code: Select all
$ sudo a2dismod reqtimeout
$ sudo service apache2 restart


So you can test if it's a Apache wait time out, if this solves it, enable it again an try too play with values, otherwise you make Apache more vulnerable for ddos attacks..
Regards, Ron.
User avatar
RDNZL
Forum Moderator
Forum Moderator
 
Posts: 991
Joined: September 2006
Location: Dordrecht, The Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Digit » Fri Feb 21, 2014 8:22 pm

Richard,

I get this, does this mean it's working? :lol: :lol:

lalaknipsel.PNG
lalaknipsel.PNG (7.12 KiB) Viewed 6483 times
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Kroonen » Fri Feb 21, 2014 8:49 pm

Ron,

That solves it. thnx

@Robert,

Now te values are now better. Ialalalla :lol: :lol:

regards Richard
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Postby Kroonen » Wed Feb 26, 2014 8:27 pm

@robert,

You have also value total power usage. I think it's the normal + low tariff.

How do I did you write it in node.js, within the smartmeter.js that reads de p1 meter

regards Richard
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands


Return to MQTT & Node.js

Who is online

Users browsing this forum: No registered users and 1 guest