How to prevent loopback publish when mosquitto bridged with RabbitMQ MQTT? - rabbitmq

I have two mosquitto brokers installed on PC1 (mosquitto v1.4.8) and PC2 (RabbitMQ v3.6.2 with MQTT Adapter).
Bridging initiated at PC1 like below
sensor/room1/ <-> office/room1/
But I noticed there is always a duplicate message being published back whenever the bridge is active, means all my application (on PC1) which subscribes to the same topic will receives the same message twice. What setting I did wrong here?
PC1 mosquitto.conf
connection bridge-pc1-to-pc2
address pc2-address.com
topic room1/# both 2 sensor/ office/
bridge_protocol_version mqttv311
notifications true
cleansession true
try_private false
To test loopback issue, I had PC1 subscribed to topic sensor/#
mosquitto_sub -t sensor/# -v -d
Then at PC1 I publish a test message
mosquitto_pub -t sensor/room1/temperature -m '{"value":27.3, "timestamp":"2016-06-03 14:02:38"}'
Broker at cloud (PC2) received the message correctly (message received only once)
Client mosqsub/3121-Dennis-iMa sending CONNECT
Client mosqsub/3121-Dennis-iMa received CONNACK
Client mosqsub/3121-Dennis-iMa sending SUBSCRIBE (Mid: 1, Topic: office/#, QoS: 0)
Client mosqsub/3121-Dennis-iMa received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/3121-Dennis-iMa received PUBLISH (d0, q0, r0, m0, 'office/room1/temperature', ... (14 bytes))
office/room1/temperature {"value":27.3, "timestamp":"2016-06-03 14:02:38"}
But PC1 received the same message twice! Below is the Pi's output
Received CONNACK
Received SUBACK
Subscribed (mid: 1): 0
Received PUBLISH (d0, q0, r0, m0, 'sensor/room1/temperature', ... (14 bytes))
sensor/room1/temperature {"value":27.3, "timestamp":"2016-06-03 14:02:38"}
Received PUBLISH (d0, q0, r0, m0, 'sensor/room1/temperature', ... (14 bytes))
sensor/room1/temperature {"value":27.3, "timestamp":"2016-06-03 14:02:38"}
Why there is loopback published message and how to solve this?
Update 3 Jun 2016
This is not the same question with this question, as it does not involve horizontal scaling (1-to-many brokers)

Change try_private false to try_private true. This is exactly what it is intended for. If rabbit doesn't support that feature (it is currently not in the spec, but widely used) then you're out of luck.

RabbitMQ doesn't support try_private and doesn't know anything about the bridge. So messages published to office/* in RabbitMQ will be sent back to subscribed mosquitto without taking to account any private flags.
To remove cycles you can use different topic names for in and out connections or use two mosquitto servers.

Related

RabbitMQ Ack Timeout

I'm using RPC Pattern for processing my objects with RabbitMQ.
You suspect,I have an object, and I want to have that process finishes and After that send ack to RPC Client.
Ack as default has a timeout about 3 Minutes.
My process Take long time.
How can I change this timeout for ack of each objects or what I must be do for handling these like processess?
Modern versions of RabbitMQ have a delivery acknowledgement timeout:
In modern RabbitMQ versions, a timeout is enforced on consumer delivery acknowledgement. This helps detect buggy (stuck) consumers that never acknowledge deliveries. Such consumers can affect node's on disk data compaction and potentially drive nodes out of disk space.
If a consumer does not ack its delivery for more than the timeout value (30 minutes by default), its channel will be closed with a PRECONDITION_FAILED channel exception. The error will be logged by the node that the consumer was connected to.
Error message will be:
Channel error on connection <####> :
operation none caused a channel exception precondition_failed: consumer ack timed out on channel 1
Timeout by default is 30 minutes (1,800,000ms)note 1 and is configured by the consumer_timeout parameter in rabbitmq.conf.
note 1: Timeout was 15 minutes (900,000ms) before RabbitMQ 3.8.17.
if you run rabbitmq in docker, you can describe volume with file rabbitmq.conf, then create this file inside volume and set consumer_timeout
for example:
docker compose
version: "2.4"
services:
rabbitmq:
image: rabbitmq:3.9.13-management-alpine
network_mode: host
container_name: 'you name'
ports:
- 5672:5672
- 15672:15672 ----- if you use gui for rabbit
volumes:
- /etc/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
And you need create file
rabbitmq.conf
on you server by this way
/etc/rabbitmq/
documentation with params: https://github.com/rabbitmq/rabbitmq-server/blob/v3.8.x/deps/rabbit/docs/rabbitmq.conf.example

Mosquitto ACL, Redis backend not working with topic having space

I am working on Mosquitto, and using Redis as the back end to handle both username/password pair authentication and ACL. I am using JPmens' authentication plugin to do this.
mosquitto conf:
auth_opt_backends redis
auth_plugin /etc/mosquitto/auth-plug.so
auth_opt_redis_host 127.0.0.1
auth_opt_redis_port 6379
auth_opt_redis_userquery GET %s
auth_opt_redis_aclquery GET %s-%s
Everything is working fine. But when I start using topic with spaces, it simply denied me from publish/subscribe.
I have already set this topic value in Redis:
SET "user1-sample topic" 2
Mosquitto logs:
Denied PUBLISH from sample_publisher (d0, q2, r0, m1, 'sample topic', ... (10 bytes))
Is there anything, I can do to make this work, like acl query change or change in redis-data.
Looking at this question and answers it implies that the following query may work:
auth_opt_redis_aclquery GET "%s-%s%"

Masstransit RabbitMq Request/Response cannot create auto-delete exchange

We are trying to implement a request/response scenario where the messages will be deleted server(consumer) is down. We start with no exchanges / queues in the rabbit mq installation.
There is a server which creates its own exchange / queue and we want this to be auto-delete=true.
In case the server is up before the client, the exchange is created with the correct configuration. But when the client is up we get this error:
RabbitMQ.Client.Exceptions.OperationInterruptedException: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - inequivalent arg 'auto_delete' for exchange 'simple_request' in vhost '****': received 'false' but current is 'true'", classId=40, methodId=10, cause=
In case the client is up first, and tries to send a message an exchange is created with the queue name that we have defined but it is not auto-delete=true which results to error:
RabbitMQ receive transport failed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - inequivalent arg 'auto_delete' for exchange 'simple_request' in vhost '****': received 'true' but current is 'false'", classId=40, methodId=10, cause=RabbitMQ receive transport failed: The supervisor is stopping, no additional scopes can be created
when the server is eventually started.
How do we implement auto-delete queues in a request response scenario?
You can update the URI in your client for the service queue to include query string parameters so that the queue is created properly.
rabbitmq://host/vhost/queue?autodelete=true&durable=false
Note I included durable=false but that's only if you're using a non-durable queue and I wanted to be complete.

Mule Syslog Inbound-Endpoint

I am attempting to create an inbound Mule endpoint that will receive Syslog messages from a remote server. The messages are recieved on port 514 using UDP packets.
As I've seen no built-in Mule support for syslog packets, I've tried to start dealing with this by creating a simple UDP connector on that port to receive the actual messages. However, when I raise the endpoint, I see no such messages received (outputed the data to stdio in order to check). When I do send "normal" UDP messages, they do come up on that endpoint. Additionally, I Installed a syslog server and verified that the syslog messages are indeed being received to my host computer.
My question is: how can I go about setting up that endpoint to receive syslog messages? Right now I'm working with this simple configuration:
<udp:inbound-endpoint host="localhost" port="514" exchange-pattern="one-way"/>
<stdio:outbound-endpoint system="OUT"/>
Your inbound endpoint looks correct. It should receive a mule message for each UDP packet received by that endpoint. The message's payload will be a byte array containing the packet's contents. You can dump each one with the following syntax:
<udp:inbound-endpoint host="localhost" port="514" exchange-pattern="one-way"/>
<logger level="WARN"/> <!-- dumps the message metadata -->
<logger level="WARN" message="[#payload:]"/> <!-- dumps the message payload-->
You'll see the payload being a byte array. To process it as a SYSLOG message, you'll need to write (or call) some Java code which understands the SYSLOG packet format.

How to receive sms via smpp connection - Kannel

I sent messages through smpp connection (using selenium SmppSim) from Kannel and it worked.
But somehow when I try to receive messages or in other words when I try to send messages from SmppSim It doesn't work. The MO messages of the SmppSim queue into the MO-queue.
I tried these things.
Used same port for send and receive (Kannel/SmppSim).
Used different ports for send and receive (Kannel/SmppSim).
Two groups for same smsc-smpp for send and receive. (It may be wrong)
Now I'm using port 2775 for send and port 2776 for receive.
#kannel.conf
group=smsc
smsc=smpp
....
port = 2775
receive-port = 2776
transceiver-mode = true
....
In SmppSim
#smppsim.props
SMPP_PORT=2775
....
SYSTEM_IDS=smppclient
PASSWORDS=password
OUTBIND_ENABLED=true
OUTBIND_ESME_IP_ADDRESS=127.0.0.1
OUTBIND_ESME_PORT=2776
OUTBIND_ESME_SYSTEMID=smppclient
OUTBIND_ESME_PASSWORD=password
....
When I run the bearerbox, it shows like below. (sms send is working)
....
connect failed
System error 111: Connection refused
ERROR: error connecting to server `localhost' at port `2776'
SMPP[SMPPSim]: Couldn't connect to server.
SMPP[SMPPSim]: Couldn't connect to SMS center (retrying in 10 seconds).
....
How do I configure this?
Thank you!
Please read SMPP v3.4 specification, part 2.2.1.
The purpose of the outbind operation is to allow the SMSC signal an ESME to originate a
bind_receiver request to the SMSC.
So it's used for SMSC (SMPPSim) to connect to ESME (Kannel) and request for callback connection.
However you can run few SMPPSim instances listening on different ports. Each instance should use own configuration file this case.