Nodemcu cannot connect to mqtt

Thanks Friend .. I was wrong and not checked the debug node menu

Looks Mqtt is perfectely working but why my nodemcu is unable to connect to mqtt..
What could be the reason ..

If I use the ip address 192.168.43.160 as server then mqtt not connect , but if i use server as localhost the mqtt connected and the test is successful .. How can solve the issue, looks like the something is wrong with ip address , but I checking my ip by cmd ipconfig .. and in firewall also allowed .. what else do i need to check i am not getting .

My ip configuration is set to auto , not manual , if that could be the reason ?

Yes, if the IP of the Broker changed then it wouldn't connect and if the IP of the Broker changed and the NodeMCU points to the old IP, then the Nodemcu would not be able to connect.

But with the current ip also not connect .. if i modify the ip everywhere (arduino program, node flows) and put the present ip , still can't connect

is the broker configured to only listen to local connections ?

how to check that ?

you need to look at the documentation of mosquitto 2.0.4 for windows 64

I think it may be the listener port option:

listener port [bind address/host/unix socket path]

Listen for incoming network connection on the specified port. A second optional argument allows the listener to be bound to a specific ip address/hostname. If this variable is used and neither the global bind_address nor port options are used then the default listener will not be started.

The bind address/host option allows this listener to be bound to a specific IP address by passing an IP address or hostname. For websockets listeners, it is only possible to pass an IP address here.

On systems that support Unix Domain Sockets, this option can also be used to create a Unix socket rather than opening a TCP socket. In this case, the port must be set to 0, and the unix socket path must be given.

This option may be specified multiple times. See also the mount_point option.

Not reloaded on reload signal.

# listener port-number [ip address/host name/unix socket path]
#listener

# By default, a listener will attempt to listen on all supported IP protocol
# versions. If you do not have an IPv4 or IPv6 interface you may wish to
# disable support for either of those protocol versions. In particular, note
# that due to the limitations of the websockets library, it will only ever
# attempt to open IPv6 sockets if IPv6 support is compiled in, and so will fail
# if IPv6 is not available.
#
# Set to `ipv4` to force the listener to only use IPv4, or set to `ipv6` to
# force the listener to only use IPv6. If you want support for both IPv4 and
# IPv6, then do not use the socket_domain option.

It saying it is open to all ip's

it is saying it is listening to all ip's

have you reveriied that that is still the IP of the windows machine?

The Ip changed but I have changed the ip in flow and arduino program also .. i am always using the latest ip in the program to test it ..

So with the new ip set in the MQTT nodes does the test flow work?

Test flow only works when i set server as "localhost" .. if i set server "192.168 .xx.xx " (my system ip address ) then mqtt only shows connecting and test flow does not work

Since I don't have a windows computer, there is not much else I can offer except suggest you install mosquitto on another device and see if you can connect to that device with it's IP address (a Pi would work)

I appreciate .. Thanks

Can you check, that your mosquitto.conf file contains the following lines:

allow_anonymous true
listener 1883

If not, add these.

Regards

1 Like

Before the config file is like
before edit (2)

I edit as you said

But still port is listening to 127.0.0.1 , not the ip address of machine ,still i am unable to connect node-red mqtt flow if i use machine ip as mqtt server. still fail

port 1883 listening (2)

Hi .. thats not how Firewizard52 wrote the two commands
Lose the # infront of the commands, as these comment out the line.

allow_anonymous true
listener 1883

after that restart your mosquitto server and try reconnecting with the 192.168.43.160 ip