|
|
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 |
Eclipse User |
|
|
|
C Xie wrote on Tue, 30 March 2021 14:07I 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
|
|
|
Powered by
FUDForum. Page generated in 0.03964 seconds