harsh.basarikodi
Posts: 3
Joined: Tue May 29, 2018 9:06 am

Getting Error: The connection was refused after executing mqtt_pub command

Tue May 29, 2018 1:52 pm

Hi ,
I am using the Raspberry Pi-3 board. I have installed the thingsboard server(1.4) and thingsboard gateway.(1.4) on it.
Also installed the have Mqtt.(1.5).Taken care of starting all the required services.(Thingsboard and tb-gateway).
Copied the access token in to the tb-gateway.yml .
1)Things board MQTT parameters settings
MQTT server parameters
mqtt:
enabled: "${MQTT_ENABLED:true}"
bind_address: "${MQTT_BIND_ADDRESS:0.0.0.0}"
#bind_port: "${MQTT_BIND_PORT:1883}"
bind_port: "${MQTT_BIND_PORT:1883}" # Changed as thingsboard and mqtt server running on same port
adaptor: "${MQTT_ADAPTOR_NAME:JsonMqttAdaptor}"
timeout: "${MQTT_TIMEOUT:10000}

2)Thingsboard gateway service running as local service on Raspberry Pi3, tb-gateway.yml file for the mqtt parameters

server:
# Server bind address
address: "0.0.0.0"
# Server bind port
port: "9090"

# Check new version updates parameters
updates:
# Enable/disable updates checking.
enabled: "${UPDATES_ENABLED:true}"

gateways:
tenants:
-
label: "Tenant"
reporting:
interval: 60000
persistence:
type: file
path: storage
bufferSize: 1000
connection:
host: "${GATEWAY_HOST:localhost}"
port: 1883
retryInterval: 3000
maxInFlight: 1000
security:
accessToken: "${GATEWAY_ACCESS_TOKEN:RASPBERRY_PI_DEMO_TOKEN}"
remoteConfiguration: true
extensions:
-
id: "http"
type: "HTTP"
extensionConfiguration: http-config.json

These are the above settings which i configured.
I am using the raspberrypi board and using it both as thingsboard server and gateway also.

1st issue as per the below link:
https://thingsboard.io/docs/iot-gateway ... figuration
I am not able to see the sync enabled after importing the dowloaded file mqtt-gui-extension-configuration.json
It always shows not synced

2 nd issue is
When i publish the mqtt message
mosquitto_pub -h localhost -p 1883 -t "sensors" -m '{"serialNumber":"TB-GW-SN-001","model":"TB-GW-T1000","temperature":35.2}'
I am not able to see the devices list in my thingsboard devices section.
I a have runned the mosquitto using command
mosquitto -v
and able to see the mosuqitto process running.

Please let me know where there is a configuration mistake!!!!

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

Re: Getting Error: The connection was refused after executing mqtt_pub command

Tue May 29, 2018 3:21 pm

Remove

Code: Select all

listener 1883
from your config files. It's due to a bug in Mosquitto 1.5.
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.

harsh.basarikodi
Posts: 3
Joined: Tue May 29, 2018 9:06 am

Re: Getting Error: The connection was refused after executing mqtt_pub command

Wed May 30, 2018 9:06 am

Thank you for the reply.
I didnot find the word listener 1883 in any config files,instead in all the config files it is mentioned as port:1883.
Did you mean the port:1883 ?
If yes May I know where all I have to remove the port:1883?
1st
I have thingsboard.yml file in /etc/thingsboard/conf/ and in this file in the mqtt parameters list it is used, I have assigned it to port:1882 ,whether this also needs to be removed?
2nd
I have tb-gateway.yml and mqtt-confi.json file in /etc/tb-gateway/conf/ where port 1883 is mentioned.Whether this needs to be removed?

I forgot to mention the OSrunning on pi board, I am using the version = 8(jessie)

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

Re: Getting Error: The connection was refused after executing mqtt_pub command

Wed May 30, 2018 9:27 am

It's a bug. Just take out all definitions for listener 1883 and port 1883 and Mosquitto will automatically use port 1883 (whether you want it to or not).

My config looks like

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

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d
and there's nothing in /etc/mosquitto/conf.d apart from the README.
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.

harsh.basarikodi
Posts: 3
Joined: Tue May 29, 2018 9:06 am

Re: Getting Error: The connection was refused after executing mqtt_pub command

Fri Jun 01, 2018 8:44 am

Thank you Dougie Lawson.

The config file of mosquitto file looks the same as shared by you.

I was able to send the data using the below command and see the device on the server!
mosquitto_pub -h localhost -p 1882 -t "sensors" -m '{"serialNumber":"TB-GW-SN-001","model":"TB-GW-T1000","temperature":35.2}'

Below are the changes:
1st:
As suggested by you mosquitto uses 1883 default port without any argument running,So explicitly used the command
mosquitto -p 1882 to run the mosquitto on port 1882.

2nd made sure that
mqtt-config.json file in the /etc/tb-gateway/conf / is binded to port 1882.

Rest all the port settings are not changed(Whatever the Port is assigned after installing tb-gateway and thingsboard )

Return to “Off topic discussion”

Who is online

Users browsing this forum: No registered users and 4 guests