Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mosquitto » How to make the broker accept clients from local network?(How to make broker work within a local network?)
How to make the broker accept clients from local network? [message #1839863] Tue, 30 March 2021 14:07 Go to next message
C Xie is currently offline C XieFriend
Messages: 1
Registered: March 2021
Junior Member
I am new to mosquitto.
I downloaded the source code mosquitto v2.0.9 and build / installed into Ubuntu 18.04 in following command:
1. make binary
2. sudo make install

After installed successfully, I tested in following commands in three terminal respectively in the same computer:

broker: mosquitto -v -p 38298
publisher: mosquitto_pub -h localhost -p 38298 -t msg -m "test"
subscriber: mosquitto-sub -h localhost -p 39298 -t msg

They are working fine.

But, when created a simple config file test.conf as below:
listener 38298
protocol mqtt

and run following command in three terminal in the same computer:
broker: mosquitto -v -c test.conf
publisher: mosquitto_pub -h 192.168.0.81 -p 38298 -t msg -m "test"
subscriber: mosquitto-sub -h 192.168.0.81 -p 39298 -t msg

The connection refused by broker. The error message is as below
1617110610: New connection from 192.168.0.81:34758 on port 38298.
1617110610: Sending CONNACK to 192.168.0.81 (0, 5)
1617110610: Client <unknown> disconnected, not authorised.

How can I make it works properly?
Thanks

CX
Re: How to make the broker accept clients from local network? [message #1839949 is a reply to message #1839863] Thu, 01 April 2021 20:41 Go to previous messageGo to next message
Roger Light is currently offline Roger LightFriend
Messages: 90
Registered: September 2013
Member
When you create your configuration file as you describe, you have not included any means of authentication and you must do this otherwise no clients will be able to authenticate. Either choose an authentication method - password file or plugin (mosquitto dynamic security, mosquitto-go-auth for example), or set `allow_anonymous true` if you do not need authentication.

Some links:

https://mosquitto.org/documentation/authentication-methods/
https://mosquitto.org/documentation/dynamic-security/

I hope that helps.

Regards,

Roger
Re: How to make the broker accept clients from local network? [message #1859291 is a reply to message #1839863] Fri, 26 May 2023 22:12 Go to previous message
Eclipse UserFriend
C Xie wrote on Tue, 30 March 2021 14:07
I am new to mosquitto.
I downloaded the source code mosquitto v2.0.9 and build / installed into Ubuntu 18.04 in following command:
1. make binary
2. sudo make install

After installed successfully, I tested in following commands in three terminal respectively in the same computer:
Best Car Broker
broker: mosquitto -v -p 38298
publisher: mosquitto_pub -h localhost -p 38298 -t msg -m "test"
subscriber: mosquitto-sub -h localhost -p 39298 -t msg

They are working fine.

But, when created a simple config file test.conf as below:
listener 38298
protocol mqtt

and run following command in three terminal in the same computer:
broker: mosquitto -v -c test.conf
publisher: mosquitto_pub -h 192.168.0.81 -p 38298 -t msg -m "test"
subscriber: mosquitto-sub -h 192.168.0.81 -p 39298 -t msg

The connection refused by broker. The error message is as below
1617110610: New connection from 192.168.0.81:34758 on port 38298.
1617110610: Sending CONNACK to 192.168.0.81 (0, 5)
1617110610: Client <unknown> disconnected, not authorised.

How can I make it works properly?
Thanks

CX

The error message "Client <unknown> disconnected, not authorized" suggests that the broker is rejecting the connection due to a lack of authorization. This issue might be related to the configuration file or the authentication settings.

To troubleshoot and resolve the problem, you can try the following steps:

Check the configuration file: Ensure that the test.conf file is correctly formatted and contains the necessary configurations. Specifically, verify that the listener port and protocol are correctly specified. You may also want to check if there are any additional configuration options related to authentication or authorization.

Review the access control settings: In the test.conf file or the default mosquitto.conf file, check if there are any access control lists (ACLs) defined. ACLs determine which clients are allowed to connect and publish/subscribe to specific topics. Make sure the ACLs are properly configured to allow connections from your publisher and subscriber.

Verify authentication settings: If authentication is enabled, check if the publisher and subscriber are providing valid credentials when connecting to the broker. This could involve usernames, passwords, or other forms of authentication depending on your configuration. Ensure that the provided credentials match the ones specified in the broker's configuration file.

Restart the broker: After making any changes to the configuration file, restart the broker to ensure the new settings take effect.

Check firewall or network settings: Ensure that there are no firewall rules or network restrictions blocking the communication between the publisher/subscriber and the broker. Verify that the necessary ports (38298 and 39298) are open and accessible.

By going through these steps and ensuring the configuration settings are correct, you should be able to resolve the "connection refused" issue and establish a successful connection between the publisher, subscriber, and broker.

[Updated on: Fri, 26 May 2023 22:13] by Moderator

Report message to a moderator

Previous Topic:Wireless Sensor+ Google Sheet+MQTT
Next Topic:QOS 0 question
Goto Forum:
  


Current Time: Fri May 03 03:12:57 GMT 2024

Powered by FUDForum. Page generated in 0.03214 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top