Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mosquitto » Connection error(a connection could not be established because the target computer refused to connect )
Connection error [message #1838367] Tue, 23 February 2021 11:15 Go to next message
David Siemens is currently offline David SiemensFriend
Messages: 2
Registered: February 2021
Junior Member
Hello,

I´m new to the whole mqtt-world and need a little help. Also sorry for my bad english i´m not a native speaker.

I´m trying to set up a mosquitto publisher and subscriber.

I´m using mosquitto v5.
I`m running it as an admin.
The broker is running on a Windows 10 Enterprise 2016.

First i tried to sub/pub on my local device with two cmd-windows. It worked perfectly fine.

I used this code for pub:
"C:\mosquitto>mosquitto_pub -t Test -m "Hello"
and for sub:
"C:\mosquitto>mosquitto_sub -t Test/#
Hello

Then i tried to setup up a second Computer as the subscriber.
I made a new rule for port 1883 on both devices and it´s activ.

I connected both devices via Ethernet and then i have assigned static IP addresses for both devices. I even logged of my Wifi and shut down my firewall. Because nothing has worked out so far.
Publisher is '192.168.2.5'
Subscriber is '192.168.2.4'

Then i used this code for the subscriber.
"C:\mosquitto>mosquitto_sub -h '192.168.2.5' -p 1883 -t Test/#
The result was this error: : "error: a connection could not be established because the target computer refused to connect."

What am i doing wrong?

Re: Connection error [message #1838433 is a reply to message #1838367] Wed, 24 February 2021 20:08 Go to previous messageGo to next message
Roger Light is currently offline Roger LightFriend
Messages: 90
Registered: September 2013
Member
Hi David,

If you're using Mosquitto 2.0 onwards, then by it doesn't allow connections from outside computers without you configuring it to do so. If you add the following to your configuration file, it will create a listener (i.e. where clients can connect) on port 1883 and allow anonyous / unauthenticated access. Please do consider using authentication and encryption once you stop testing though.

The configuration file should be at C:\Program Files\mosquitto\mosquitto.conf - make the changes then restart the Mosquitto service, or manually restart if that is what you are doing, then everything should be working.

listener 1883
allow_anonymous true


Regards,

Roger
Re: Connection error [message #1838453 is a reply to message #1838433] Thu, 25 February 2021 11:27 Go to previous message
David Siemens is currently offline David SiemensFriend
Messages: 2
Registered: February 2021
Junior Member
Hi Roger,

i forgot to mention that i set 'allow_anonymous false' .
But I created a password file and it should be possible to have access via the username and password.

Luckily I was able to fix the problem by installing an older version of the mosquitto broker. Now everything works fine and it´s possible to subscribe and publish from my other device.

Regards,

David
Previous Topic:New Mosquitto install - not talking outside of localhost
Next Topic:mosquitto refuses connection sometimes
Goto Forum:
  


Current Time: Wed Apr 24 13:37:12 GMT 2024

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

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

Back to the top