Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT_Publish() return MQTTSuccess,but the message is not being published to broker successfuly #1900

Open
zhengasif opened this issue Jan 8, 2024 · 6 comments

Comments

@zhengasif
Copy link

hi teams
I'm using the latest version of embedded sdk in my arm-linux device. I found an error that MQTT_Publish() return MQTTSuccess,but in fact there are no messages in broker ,and after 5 seconds it returns MQTTKeepAliveTimeout because of the bad network condition.I set QOS0 for my msgs.
why it is like that in poor network condition?
my code is like below:
mqttStatus = MQTT_Publish( &AwsMqttContext,&outgoingPublishPackets[publishIndex].pubInfo,outgoingPublishPackets[publishIndex ].packetId);
if(mqttStatus!=MQTTSuccess )
{
printf("Failed to send PUBLISH packet to broker with error = %s.",MQTT_Status_strerror(mqttStatus));
returnStatus = EXIT_FAILURE;
cleanupOutgoingPublish( publishIndex );
}
else
{
printf( "PUBLISH sent for topic %.*s to broker with packet ID %u.\n\n",strlen(pub_topic),pub_topic,outgoingPublishPackets[ publishIndex ].packetId);
}
The log file is in the attachment.
sendnook

@zhuang-hy
Copy link

zhuang-hy commented Jan 8, 2024 via email

@aggarg
Copy link
Member

aggarg commented Jan 9, 2024

Can you check what does your transport send/writev function return? If it returns success, MQTT has no way to determine that the data was not actually sent. In that case the MQTT keep alive should detect broken connection, which it seems to do. If the transport send does not return success, then it may be a bug in the library to return success.

@zhengasif
Copy link
Author

hi
I check the return of send function, it return scuccess but no msg in my broker.
For this case, how can I do to make my code more robust, set qos1 or add some other code to check the return msg?

sendmsg001
sendmsg002
sendmsg003

@Skptak
Copy link
Member

Skptak commented Jan 24, 2024

Hey @zhengasif sorry that you've been seeing this issue. I was wondering if you've verified that you're able to connect to the broker with the credentials that you're using on your device?

If you have verified this could you then try hosting, and then connecting to, a local MQTT broker? This way you can inspect the packets that are coming into and out of the broker using Wireshark or a similar utility. This would help us figure out what the root cause of your problem is

@zhuang-hy
Copy link

zhuang-hy commented Jan 24, 2024 via email

@aggarg
Copy link
Member

aggarg commented Jan 24, 2024

set qos1 or add some other code to check the return msg?

That should help to catch broken connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants