RabbitMq Mqtt : Connect Ack Error for Mqtt Publish Message #8460
Replies: 2 comments
-
Connection acknowledgment is not sent in response to publishes. It is sent in response to a client connection. Your code publishes with QoS set to 0. It’s not obvious to me what exactly the expected sequence of frames should be. There is no evidence of an issue in the broker, and no details about the RabbitMQ version used. |
Beta Was this translation helpful? Give feedback.
-
einval means the socket is already closed. With connection acknowledgment I can only imagine this with very short lived client connections. That's not really how messaging protocols, including MQTT, are meant to be used. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
RabbitMq Mqtt doesnot give Connect Ack for some messages published using paho mqtt client with qos1.The Error it shows in log is
2023-06-03 13:18:49.984295+00:00 [error] <0.9825.1> MQTT protocol error on connection 117.251.69.209:59800 -> 172.75.0.2:1883: {socket_ends,
2023-06-03 13:18:49.984295+00:00 [error] <0.9825.1>einval}
Reproduction steps
This is the Paho Mqtt code to publish the message
python 3.6
import random
import time
from paho.mqtt import client as mqtt_client
from datetime import timezone
import datetime
from random import randrange
from datetime import timedelta
import json
from datetime import timedelta, date
import pandas as pd
broker = '216.45.35.134'
port = 1884
test_topic = "python/mqtt"
client_id = f'python-mqtt-{random.randint(0, 100)}'
topic = "testpub_v2"
client_id = 'test_client_1'
username = "Device1"
password = 'Z9WNE7'
def connect_and_publish_mqtt_broker(username,password,device,project):
print(f"connect_and_publish_mqtt_broker")
# Set Connecting Client ID
client = mqtt_client.Client(client_id)
client.username_pw_set(username, password)
try:
ret=client.connect(broker, port,1)
except:
ret=1
print(f"connection=={ret}")
if ret==0:
req_count = random.randrange(1, 50)
now = datetime.datetime.now().replace(microsecond=0)
# timestamp = (now - timedelta(days=random.randrange(1,30),hours=random.randrange(1,23)))
# timestamp=(timestamp + timedelta(hours=random.randrange(1,23))).replace(second=0)
timestamp = now
datamsg = {"req_Count_total": req_count,
"project": project,
"device": device,
"time_stamp":str(timestamp),
"time_interval":req_count,
"window_1":1,
"window_2":2,
"window_3":3,
"window_4":4
}
data_msg = json.dumps(datamsg)
result = client.publish(topic, payload=(data_msg), qos=0, retain=True)
print(f"result=={result}")
status = result[0]
if status == 0:
print(f"data_msg:{data_msg}")
else:
print(f"Failed to send message to topic {topic}")
return True,datamsg
else:
return False,{}
Expected behavior
2023-06-03 13:21:00.143546+00:00 [info] <0.10249.1> accepting MQTT connection <0.10249.1> (117.251.69.209:59833 -> 172.75.0.2:1883, client id: python-mqtt-10)
2023-06-03 13:21:00.144589+00:00 [info] <0.10249.1> MQTT connection "117.251.69.209:59833 -> 172.75.0.2:1883" will terminate because peer closed TCP connection
Additional context
I am Sending the message repeatedly every 10 sec without changing the client code but it fails some time for the same code even though there is no change in payload . I also checked the wireshark logs but failed to get any helpful hint or pattern.
Beta Was this translation helpful? Give feedback.
All reactions