eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.05k stars 2.39k forks source link

Bridge not working with a specific kind of topic #3067

Open Anzal-calixto opened 4 months ago

Anzal-calixto commented 4 months ago

Here is the my broker configuration bridge file.

address broker.emqx.io:1883
#bridge_cafile /etc/mosquitto/certs/ca.crt
#bridge_certfile /etc/mosquitto/certs/client.crt
#bridge_keyfile /etc/mosquitto/certs/client.key
topic home-15646/# out 0
topic home-15646/# in 0

instead of this if give home/# the bridge will work fine.

1718281051: mosquitto version 2.0.11 starting
1718281051: Config loaded from /etc/mosquitto/mosquitto.conf.
1718281051: Opening ipv4 listen socket on port 1883.
1718281051: Opening ipv6 listen socket on port 1883.
1718281051: Connecting bridge (step 1) home_connection-15646 (test.mosquitto.org:1883)
1718281051: mosquitto version 2.0.11 running
1718281052: Connecting bridge (step 2) home_connection-15646 (test.mosquitto.org:1883)
1718281052: Error creating bridge: Broken pipe.
1718281052: New connection from 127.0.0.1:47960 on port 1883.
1718281052: New client connected from 127.0.0.1:47960 as mqttjs_1fbb6b9b (p2, c1, k60).

also its giving a broken pipe error.

Daedaluz commented 4 months ago

try

address broker.emqx.io:1883
#bridge_cafile /etc/mosquitto/certs/ca.crt
#bridge_certfile /etc/mosquitto/certs/client.crt
#bridge_keyfile /etc/mosquitto/certs/client.key
topic home-15646/# both 0

But it feels like this might be something else.

tls settings good?

Anzal-calixto commented 4 months ago

Tls settings are working fine when I try with emqx broker it's working but if I am connecting to mosquito broker it's not bridging

hardillb commented 4 months ago

Try wrapping the topic in quotes

address broker.emqx.io:1883
#bridge_cafile /etc/mosquitto/certs/ca.crt
#bridge_certfile /etc/mosquitto/certs/client.crt
#bridge_keyfile /etc/mosquitto/certs/client.key
topic "home-15646/#" out 0
topic "home-15646/#" in 0
Anzal-calixto commented 4 months ago

thanks @hardillb i tried using above method it doesn't seems to be working

Daedaluz commented 4 months ago

I think there should be a "both" variant to "in" and "out", try that instead of in and out separately.

Anzal-calixto commented 4 months ago

1719215263: Error creating bridge: Broken pipe. 1719215294: Connecting bridge (step 1) home_connection-15646(test.mosquitto.org:1883) @Daedaluz tried that still gives the same error

Daedaluz commented 4 months ago

What does emqx logs say?

Anzal-calixto commented 4 months ago

1719220419: mosquitto version 2.0.11 starting 1719220419: Config loaded from /etc/mosquitto/mosquitto.conf. 1719220419: Opening ipv4 listen socket on port 1883. 1719220419: Opening ipv6 listen socket on port 1883. 1719220419: Connecting bridge (step 1) home_connection-15646 (broker.emqx.io:1883) 1719220419: mosquitto version 2.0.11 running 1719220420: Connecting bridge (step 2) home_connection-15646 (broker.emqx.io:1883) 1719220420: New connection from 127.0.0.1:60498 on port 1883. 1719220420: New client connected from 127.0.0.1:60498 as mqttjs_b48cce68 (p2, c1, k60). 1719220473: New connection from 192.168.1.174:52561 on port 1883. 1719220473: New client connected from 192.168.1.174:52561 as mqttx_384adf50 (p5,

this is the log for emqx

Daedaluz commented 4 months ago

that looks like logs from mosquitto.

Anzal-calixto commented 4 months ago

@Daedaluz In my setting my local broker is mosquitto and when i am trying to bridge this local broker to a mosquitto broker thats when it gives the error and bridge is not being connected. If i try to bridge it to an emqx broker bridge is working fine. my cloud broker is a mosquitto broker and the emqx broker is an open broker

Anzal-calixto commented 4 months ago

@Daedaluz @hardillb any suggestions

ckrey commented 4 months ago

@Anzal-calixto "home-15646/#" is not a valid topic filter (because the # is not at the end).

Please correct to home-15646/# which is probably what you intended

ckrey commented 4 months ago

Can you try with a more recent version of mosquitto (2.0.18)? 2.0.11 is 3 years old

Anzal-calixto commented 4 months ago

@ckrey i tried home-1546/# it was also havig the issue i will update mosquitto and try again

Anzal-calixto commented 4 months ago

hello @ckrey i am using debian 11 it seems the latest version that is available for dedian 11 is 2.0.11

ckrey commented 4 months ago

Setting up a brigde to test.mosquitto.org:1883 works well with mosquitto 2.0.11 and 2.0.18

Please show us your complete config with bridge to test.mosquitto.org (all your snippets above show the config with emqx)

Anzal-calixto commented 4 months ago

sure here is the settings


address test.mosquitto.org:1883
topic home-15646/# both 0 
Anzal-calixto commented 3 months ago

@ckrey @Daedaluz @hardillb can you guys provide any other methods. it would be a great help

ckrey commented 3 weeks ago

@Anzal-calixto Would you retry with this mosquitto.conf and show us your mosquitto output?:

log_dest stderr
log_type all
connection_messages true
allow_anonymous true
connection home_connection-15646
address test.mosquitto.org:1883
topic home-15646/# both 0

It works perfectly here

1728462102: mosquitto version 2.0.19 starting
1728462102: Config loaded from mosquitto-bridge.conf.
1728462102: Starting in local only mode. Connections will only be possible from clients running on this machine.
1728462102: Create a configuration file which defines a listener to allow remote access.
1728462102: For more details see https://mosquitto.org/documentation/authentication-methods/
1728462102: Opening ipv4 listen socket on port 1883.
1728462102: Opening ipv6 listen socket on port 1883.
1728462102: Bridge local.C1.local.home_connection-15646 doing local SUBSCRIBE on topic home-15646/#
1728462102: Connecting bridge home_connection-15646 (test.mosquitto.org:1883)
1728462102: Bridge C1.local.home_connection-15646 sending CONNECT
1728462102: mosquitto version 2.0.19 running
1728462102: Received CONNACK on connection local.C1.local.home_connection-15646.
1728462102: Bridge local.C1.local.home_connection-15646 sending SUBSCRIBE (Mid: 2, Topic: home-15646/#, QoS: 0, Options: 0x00)
1728462102: Received PUBACK from local.C1.local.home_connection-15646 (Mid: 1, RC:0)
1728462103: Received SUBACK from local.C1.local.home_connection-15646
ckrey commented 6 days ago

@Anzal-calixto any update?