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

Post Reply
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

mqtt and Apache and mod_websocket_mosquitto

Post by Kroonen »

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: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Kroonen »

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: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Kroonen »

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
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Digit »

Have you checked the Apache logs, any strange messages in there?
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Kroonen »

Robert

No errrors in log from apache.

Have youj som html code to test?

regards Richard
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Bwired »

We are not using apache as a webserver, i think Willem is the only one, but not sure.....
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Digit »

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.
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Kroonen »

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
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Re: mqtt and Apache and mod_websocket_mosquitto

Post by RDNZL »

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.
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Digit »

Richard,

I get this, does this mean it's working? :lol: :lol:
lalaknipsel.PNG
lalaknipsel.PNG (7.12 KiB) Viewed 16610 times
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Kroonen »

Ron,

That solves it. thnx

@Robert,

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

regards Richard
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

Re: mqtt and Apache and mod_websocket_mosquitto

Post by Kroonen »

@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
Post Reply

Return to “MQTT & Node.js”