Error: connection refused [mosquitto_sub -v -t "gateway/+/rx"]


#1

I am doing some troubleshooting on my Gateway Bridge and have come to the last step which is calling mosquitto_sub -v -t “gateway/+/rx” command. It gives me an error: connection refused.

There is no password set for connecting to mosquitto and .conf file contains anonymous true so I am not sure what could be causing this problem?

Anyone had this problem before? (couldn’t find it in existing posts)


#2

It doesn’t seem to be an authorization issue, you’d get a Connection Refused: not authorised error message in that case. Instead, if I try to connect using a wrong port (I’m running mosquitto at 1883), e.g. mosquitto_sub -h localhost -p 1900 -v -t “gateway/+/rx, I get Error: Connection refused as a response. So maybe check with explicit host and port?

Of course, check that mosquitto is actually running too.


#3

The port is set to 1883.

Feeling pretty dumb asking this but how would I check if mosquitto is actually running? I’ve been given a GW, loraserver which were “all set up” and I am kind of in the dark with all of this because it was supposed to be working :slight_smile:


#4

Try with ps -A | grep -i mosquitto. If it’s a service, sudo service mosquitto status (or sudo systemctl status mosquitto) will show the service’s status.


#5

Tried both. First one does nothing and the second one got me this message. Looks like it started and exited?


#6

Looks like it’s running on server.


#7

As opposed to what, the gateway? Could you clarify your setup? It seems you are running two mosquitto instances, which is odd. In any case, I’d recommend reading the project’s overview and the architecture found there, and then check the whole documentation to see what your deployment shoulkd look like.


#8

Yes, as opposed to gateway. Did you see both my posts? The first one is from the GW and the second one from the server. It looks like mosquitto starts and exits immediately on GW from what I see above (not sure).

Thing is this setup I have has been given to me and I haven’t been changing anything. It should be done correctly and follow the architecture guide you provided.

In the notes I have been given it says mosquitto has been deployed on server.


#9

Okay, I got the JSON when I ran this command on the server:
mosquitto_sub -v -t “application/+/device/+/+” so it looks like it’s working.


#10

What I meant is that it doesn’t make sense to have a mosquitto broker in your gateway if you have an external loraserver. You run mosquitto on the gateway when you want to run all the loraserver stack locally, because lora-gateway-bridge, loraserver and lora-app-server connect to the same broker. In a typical layout, the broker is running in a server that’s reachable by all 3 services, however they are deployed (e.g., we run lora-gateway-bridge at our gateways, and loraserver + lora-app-server + mosquitto at a central server, but you could use different machines for those as long as they are reachable).

Anyway, it seems originally you tried to subscribe to the broker at the gateway and it wasn’t running (though if it was it would still be wrong to try to do it, as the server’s broker is the one working with your stack), so problem solved.


#11

Yeah I see what you mean and this is the setup we are using:

RPI: lora-gateway-bridge

Ubuntu: lora app server + lora server + mosquitto

I have other problems to solve now, such as figuring out how to manually set data rate and transmit duty cycle in I-CUBE-LRWAN example code. Been bashing my head with this today.

Thanks for the help!