Page 2 of 3

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Sun Nov 29, 2015 4:05 pm
by mbajlo00
I connected my local client to the local network, just like I use to before bridging. In a mattter of fact bidging two brokers is the only change I've made. I'm using ESP8266 as a client programmed in arduino IDE and using pubsub library which supports only qos= 0. The problem is that local client is connected and powered up. Everything is just like before but the messages are not getting through. I don't know am I missing something, but I understood that after the bridging is done, clients should stay the same.

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Mon Nov 30, 2015 11:08 am
by mbajlo00
I wrote a java client, and it works without problem if don't bridge brokers, but after bridging it gave me this error:

Code: Select all

excep Unable to connect to server (32103) - java.net.ConnectException: Connection refused: connect
Unable to connect to server (32103) - java.net.ConnectException: Connection refused: connect
	at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:79)
	at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:590)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
	at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
	at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
	at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.SocksSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:70)
	... 2 more
don't know why it keep saying connection refused?

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 02, 2015 11:32 am
by mbajlo00
I've solved some of the problems, but now when I try to see mosquitto log by writing:

Code: Select all

mosquitto
in terminal, I get this:
log.gif
mosquitto log
log.gif (4.37 KiB) Viewed 6133 times
my mosquitto.conf file looks like this:
mosquitto_conf.gif
mosquitto.conf
mosquitto_conf.gif (11 KiB) Viewed 6133 times
what means

Code: Select all

ERROR: Address already in use
in mosquitto log?

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 02, 2015 12:46 pm
by mbajlo00
I've found out why I'me getting this error, its because mosquitto starts at startup and already using port 1883, so that is solved.
But there is still no bridge between local mosquitto and remote cloudmqtt broker, any ideas why?

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 02, 2015 1:40 pm
by DougieLawson
What is "cloudmqtt"? Who owns it? Where does it run? Have you got your credentials correct? Does "cloudmqtt" log any errors?

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 02, 2015 3:52 pm
by mbajlo00
CloudMQTT are managed Mosquitto servers in the cloud. Mosquitto implements the MQ Telemetry Transport protocol, MQTT, which provides lightweight methods of carrying out messaging using a publish/subscribe message queueing model.
I've made an account on CloudMQTT and used creditentials that are provided to me by cloudmqtt.com Control panel, the same one that I've used to connect with clients I wrote.
and my mosquitto.conf looks like this:

Code: Select all

#Place your local configuration in /etc/mosquitto/conf.d/
#
#A full description of the configuration file is at
#/usr/share/doc/mosquitto/examples/mosquitto.conf.example

connection cloudmqtt
address mnumber.cloudmqtt.com:port
topic # both 0
notifications false
start_type automatic
remote_usename username
remote_password password

pid_file /var/run/mosquitto.pid

persistance true
persistance_location /var/lib/mosquitto/

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 02, 2015 4:57 pm
by DougieLawson
Ah, there's the reason. CloudMQTT is running RabbitMQ not Mosquitto. Try switching to running that on your RPi. I'm not sure whether there's support for bridging Mosquitto to RabbitMQ.

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 02, 2015 11:17 pm
by mbajlo00
I tought about that, but from what I've had read in the documentation of cloudmqtt there is no word about RabbitMQ, where have you found that?
These are the links that provided documenation of cloudmqtt and where i've found how to bridge mosquitto:
https://www.cloudmqtt.com/docs.html ht ... tt-brokers
but I've have done few changes to mosquitto.conf file using information provided by http://mosquitto.org/man/mosquitto-conf-5.html

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Thu Dec 03, 2015 12:34 am
by DougieLawson
I must have been seeing things. It does appear to be running Mosquitto.

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Thu Dec 03, 2015 8:15 am
by mbajlo00
No problem, I meant that I've overseen something, so the bridge configuration should be ok?

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Tue Dec 08, 2015 4:11 pm
by mbajlo00
I've checked with cloudmqtt and they say everything should be fine.
I have looked into log file and there is a line that says
mosquitto version 1.3.5 (build date 2014-10-18 21:06:44+0100) start$
and when I try

Code: Select all

mosquitto --version
in terminal I get:
unknown option 'mosquitto --version
mosquitto version 1.4.5 (build date Sun, 08 Nov 2015 21:43:12 +0000)
So i tried

Code: Select all

sudo apt-get install mosquitto
to upgrade mosquitto and I got:
Reading package lists... Done
Building dependecy tree
Reading state information... Done
mosquitto is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded
How it is possible to have two versions of mosquitto (1.3.5 in log file and 1.4.5 when I try mosquitto --version) and when I try to upgrade I can't, could some of this cause the problem?

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Thu Dec 10, 2015 12:06 am
by asandford
This thread has lost some posts. I posted a reply to DL about RabbitMQ, it has gone and there is a gap of 5 days.

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Fri Dec 11, 2015 12:00 am
by mbajlo00
I don't know what happend with lost posts, I haven't even seen them. Can you post those again please?

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Sun Dec 13, 2015 7:10 pm
by mbajlo00
Did somebody succeed to bridge local mosquitto to some remote broker on cloud, if yes, which remote broker was used?
I would like to use some of IOTF like IBM IOTF but there is pricing involved, so I'm not sure about that.

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Mon Dec 14, 2015 10:32 pm
by asandford
mbajlo00 wrote:Did somebody succeed to bridge local mosquitto to some remote broker on cloud, if yes, which remote broker was used?
I would like to use some of IOTF like IBM IOTF but there is pricing involved, so I'm not sure about that.
I'm curious as to what benefits a cloud broker would deliver over a local one (not trying to be argumentative here, I'd really like to know as I can't see any, or I may have missed some stunning feature).

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Tue Dec 22, 2015 9:24 am
by mbajlo00
The benefit should be that you don't need two separate clients(one for local and one for remote broker)
You just bridge local to remote remote broker, and if somehow you loose internet access you'll still have local broker working, as it should. Only remote broker client won't have access to the local broker.

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 23, 2015 12:47 am
by asandford
mbajlo00 wrote:The benefit should be that you don't need two separate clients(one for local and one for remote broker)
You just bridge local to remote remote broker, and if somehow you loose internet access you'll still have local broker working, as it should. Only remote broker client won't have access to the local broker.
Why not just make the local broker available from the 'net?

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 23, 2015 8:06 am
by DougieLawson
asandford wrote:
mbajlo00 wrote:The benefit should be that you don't need two separate clients(one for local and one for remote broker)
You just bridge local to remote remote broker, and if somehow you loose internet access you'll still have local broker working, as it should. Only remote broker client won't have access to the local broker.
Why not just make the local broker available from the 'net?
You'd need to enable and enforce the use of SSL for connectors, because otherwise you're going to have the hackers knocking on your open TCP/IP port every day.

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 23, 2015 11:55 pm
by asandford
DougieLawson wrote: You'd need to enable and enforce the use of SSL for connectors, because otherwise you're going to have the hackers knocking on your open TCP/IP port every day.
Which is not exactly hard to do, or use a different port number, or whitelist allowed connections (most of which can be done at the router level).

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Wed Dec 23, 2015 11:56 pm
by asandford
asandford wrote:
DougieLawson wrote: You'd need to enable and enforce the use of SSL for connectors, because otherwise you're going to have the hackers knocking on your open TCP/IP port every day.
Which is not exactly hard to do, or use a different port number, or whitelist allowed connections, or even tunnel it thru' a VPN (most of which can be done at the router level).

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Mon Feb 01, 2016 5:33 pm
by Johu
Hi,
I try some days to get a good working MQTT but something is wrong. At the moment the Python MQTT modul. Why?
I have update with:

Code: Select all

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
rm mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list  :!: 
sudo apt-get update
sudo apt-get install mosquitto mosquitto-clients
and I get mosquitto 1.4.7 super :D
MQTT works fine.
Now the problem with Python. I have installed 2.7.3 and 3.2.3
The Python MQTT module is 0.15 and nothing works ..
The message is:

Code: Select all

[email protected]:~$ sudo python mqtt_listener.py
Traceback (most recent call last):
  File "mqtt_listener.py", line 4, in <module>
    import mosquitto
  File "/usr/lib/pymodules/python2.7/mosquitto.py", line 484, in <module>
    _mosquitto_log_init = _libmosq.mosquitto_log_init
  File "/usr/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/arm-linux-gnueabihf/libmosquitto.so.1: undefined symbol: mosquitto_log_init
[email protected]:~$
Is there a way to correct this?
Thanks for our interest, time & help!
#
Regards Johu

Upps: Is is possible the launch of the MQTT broker after boot to forbidden? Boot without broker launch?

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Mon Feb 01, 2016 7:23 pm
by DirkS
The Python MQTT module is 0.15 and nothing works ..
What module is that? Where did you get that from?

paho-mqtt (that's the one linked to from mosquitto.org) is actually at v1.1
You can install it with

Code: Select all

sudo pip install paho-mqtt

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Tue Feb 02, 2016 7:48 am
by Johu
Hi DirkS,

thx for answer. I have a little python script:

Code: Select all

import pip
print
installed_packages = pip.get_installed_distributions()
print installed_packages
result:

Code: Select all

[wsgiref 0.1.2 (/usr/lib/python2.7), argparse 1.2.1 (/usr/lib/python2.7), pygame 1.9.1release (/usr/lib/python2.7/dist-packages), distribute 0.6.24dev-r0 (/usr/lib/python2.7/dist-packages), numpy 1.6.2 (/usr/lib/pymodules/python2.7), mosquitto 0.15 (/usr/lib/pymodules/python2.7)]
I get it with:

Code: Select all

sudo apt-get install python-mosquitto

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Tue Feb 02, 2016 8:51 am
by DirkS
Johu wrote:I get it with:

Code: Select all

sudo apt-get install python-mosquitto
That's the old python module from the Raspbian repo. It has been transferred to the Eclipse paho project (see http://mosquitto.org/documentation/python/)
See my previous post for installation instructions.
Some documentation at https://pypi.python.org/pypi/paho-mqtt/1.1
There are some examples at http://git.eclipse.org/c/paho/org.eclip ... e/examples

Re: Getting Mosquitto to work on Raspberry Pi

Posted: Tue Feb 02, 2016 9:56 am
by Johu
Hi DirkS,

many thanks for your help. All wonderful! :)

One question is allowed?
Can I forbidden the broker launch after boot?

Johu