Comments (6)
A published message's QoS is the highest among the receiver's and the sender's; if you subscribe with 2 and publish with 0, it will be sent to you as 0. It should arrive anyway because it is TCP, but it would be nice from you to also describe where are you publishing to (the broker) and how are you sure that is not the problem. Unless there is a capture file showing the broker received a proper message and attempted to deliver to either the library or the client, I wouldn't bother to look at the code for possible errors. Even though, you might be having connection problems and your session be not persistent... (a clean one). Need to see the traffic.
What are you using ?... the library ?, the client ?
If you are using the library (MQTTPacket), please describe how.
If you are using the client (C or C++ ?) I can't help, wait for someone else. However, I suggest you do the Wireshark stuff.
from paho.mqtt.embedded-c.
@scaprile
Test broker "iot.eclipse.org" port1883
I am using MQTT C client. topic_A/hardik subscribed with qos2 running on ubuntu in virtual box.
And publishing message from MQTTlens on topic topic_A/hardik with qos2 also subscribed with same topic with qos2 . MQTTlens works fine with pubsub so no u=issue on broker side.
As per your suggestion wireshark logs are attached to this comment. My client is not sending PUBCOMP message.After looking at MQTT C client code, it does not processing PUBREL message and not sending PUBCOMP message back to broker. `int cycle(MQTTClient* c, Timer* timer)
{
// read the socket, see what work is due
unsigned short packet_type = readPacket(c, timer);
if (packet_type == 0)
return FAILURE; // no more data to read, unrecoverable
int len = 0,
rc = SUCCESS;
switch (packet_type)
{
case CONNACK:
case PUBACK:
case SUBACK:
break;
case PUBLISH:
{
MQTTString topicName;
MQTTMessage msg;
int intQoS;
if (MQTTDeserialize_publish(&msg.dup, &intQoS, &msg.retained, &msg.id, &topicName,
(unsigned char**)&msg.payload, (int*)&msg.payloadlen, c->readbuf, c->readbuf_size) != 1)
goto exit;
msg.qos = (enum QoS)intQoS;
deliverMessage(c, &topicName, &msg);
if (msg.qos != QOS0)
{
if (msg.qos == QOS1)
len = MQTTSerialize_ack(c->buf, c->buf_size, PUBACK, 0, msg.id);
else if (msg.qos == QOS2)
len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREC, 0, msg.id);
if (len <= 0)
rc = FAILURE;
else
rc = sendPacket(c, len, timer);
if (rc == FAILURE)
goto exit; // there was a problem
}
break;
}
case PUBREC:
{
unsigned short mypacketid;
unsigned char dup, type;
if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1)
rc = FAILURE;
else if ((len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREL, 0, mypacketid)) <= 0)
rc = FAILURE;
else if ((rc = sendPacket(c, len, timer)) != SUCCESS) // send the PUBREL packet
rc = FAILURE; // there was a problem
if (rc == FAILURE)
goto exit; // there was a problem
break;
}
case PUBCOMP:
break;
case PINGRESP:
c->ping_outstanding = 0;
break;
}
keepalive(c);
exit:
if (rc == SUCCESS && packet_type != FAILURE)
rc = packet_type;
return rc;
}`
from paho.mqtt.embedded-c.
In Paho MQTT C-Client cycle
I don't see the switch-case to process PUBREL message. It can't reply with PUBCOMP.
If your build environment has c++ compiler with some C++11 support you can try to use my forked and reworked version of Paho C++ MQTT Client (see processPacket
method).
My project is targeted for Arduino environment but all resources including time are external so should not be a problem to use with any other environment.
from paho.mqtt.embedded-c.
same problem for me with c++.
with QOS2 it fails.
I solved making a little modification at MQTTClient.h, line 840.
from this:
#elif MQTTCLIENT_QOS2
to this:
#endif
#if MQTTCLIENT_QOS2
let me know if this solves your issue
from paho.mqtt.embedded-c.
I also opened an issue for qos2 problem specially #89
from paho.mqtt.embedded-c.
I've fixed the PUBREL case, sending of PUBCOMP, and the preprocessor definitions. For both the C and C++ clients, the Travis test using all QoSs, including QoS2, now works. Thanks.
from paho.mqtt.embedded-c.
Related Issues (20)
- Messages are not retained even if the flag is set to true HOT 2
- Suspected bug with MQTTYield() / cycle()
- Performance problem related to cycle() and MQTT_TASK HOT 2
- Is there a limit on the amount of bytes the payload must be in the publish message? HOT 6
- Are there any plans to migrate to exact-width integer types? HOT 13
- isTopicMatched() does not behave correctly for filter that terminates with wildcard /# HOT 2
- Why use `enddata - curdata` instead of `mylen` in `MQTTDeserialize_ack()`?
- MQTTPacket_decode() doesn't present errors when it should HOT 1
- Does this library support mqtt v5? HOT 6
- Memory corruptions when casting enum to `int *` HOT 1
- Client never closes socket HOT 2
- Move includes to a subdirectory HOT 3
- keepalive failed by calling MQTTYield with short timeout and short interval. HOT 4
- Potential OOB Writes in eclipse/paho.mqtt.embedded-c
- PlatformIO's last release outdate HOT 2
- Compile error when compiling MQTTV5 HOT 1
- Library linking issues HOT 2
- Facing errors while building on windows
- MQTTPacket V5
- Example MQTT Client C use SSL
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paho.mqtt.embedded-c.