Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] Maybe found a bug: Received publish not being ack'd with QOS=2 and `max_inflight_messages 1`

Hi Felipe,

max_inflight_messages applies to both incoming and outgoing messages -
this is incorrect behaviour that I've known about for a while but
isn't that important if you've not got it set too small. I'm not
entirely surprised that you're seeing odd behaviour with it set to 1.

The patch below gives a quick workaround to get the behaviour you would expect.

Something else for you to consider - are you completely sure that you
need QoS=2 and one message at a time?

Cheers,

Roger



diff --git a/src/database.c b/src/database.c
index c984477..1783bd9 100644
--- a/src/database.c
+++ b/src/database.c
@@ -395,7 +396,7 @@ int mqtt3_db_message_insert(struct mosquitto_db
*db, struct mosquitto *context,
                context->last_msg = msg;
        }
        context->msg_count++;
-       if(qos > 0){
+       if(qos > 0 && dir == mosq_md_out){
                context->msg_count12++;
        }

@@ -891,7 +892,7 @@ int mqtt3_db_message_write(struct mosquitto_db
*db, struct mosquitto *context)
                        }
                }else{
                        /* state == mosq_ms_queued */
-                       if(tail->direction == mosq_md_in &&
(max_inflight == 0 || msg_count < max_inflight)){
+                       if(tail->direction == mosq_md_in){
                                if(tail->qos == 2){
                                        tail->state = mosq_ms_send_pubrec;
                                }

On Sun, Jul 5, 2015 at 8:42 PM, Felipe de Andrade Neves Lavratti
<felipelav@xxxxxxxxx> wrote:
> I have the mosquitto broker running with `max_inflight_messages 1` in
> a very slow 6lowpan network.
>
> What the log below is showing is that the broker ignored a PUBLISH
> (the m3) from the client.
>
> Is this the expected behaviour? Should `max_inflight_messages 1`
> ignore reception as well?
>
> ```
> // PUBLISHING m1 OK QOS2 **TO** fe80::c30c:0:0:7
>
> 1436123210: Sending PUBLISH to fe80::c30c:0:0:7 (d0, q2, r0, m1,
> 'test', ... (1 bytes))
> 1436123213: Received PUBREC from fe80::c30c:0:0:7 (Mid: 1)
> 1436123213: Sending PUBREL to fe80::c30c:0:0:7 (Mid: 1)
> 1436123217: Received PUBCOMP from fe80::c30c:0:0:7 (Mid: 1)
>
> // PUBLISHING m2 OK QOS2 **FROM** fe80::c30c:0:0:7
>
> 1436123218: Received PUBLISH from fe80::c30c:0:0:7 (d0, q2, r0, m2,
> 'testout', ... (14 bytes))
> 1436123218: Sending PUBREC to fe80::c30c:0:0:7 (Mid: 2)
> 1436123221: Received PUBREL from fe80::c30c:0:0:7 (Mid: 2)
> 1436123221: Sending PUBCOMP to fe80::c30c:0:0:7 (Mid: 2)
>
> 1436123243: Received PINGREQ from fe80::c30c:0:0:7
> 1436123243: Sending PINGRESP to fe80::c30c:0:0:7
>
> // PUBLISHING m2 OK QOS2 **TO** fe80::c30c:0:0:7
>
> 1436123249: Sending PUBLISH to fe80::c30c:0:0:7 (d0, q2, r0, m2,
> 'test', ... (1 bytes))
> 1436123253: Received PUBREC from fe80::c30c:0:0:7 (Mid: 2)
> 1436123253: Sending PUBREL to fe80::c30c:0:0:7 (Mid: 2)
> 1436123254: Received PUBCOMP from fe80::c30c:0:0:7 (Mid: 2)
>
> // PUBLISHING m3 OK QOS2 **TO** fe80::c30c:0:0:7
> // PUBLISHING m3 **BAD** QOS2 **FROM** fe80::c30c:0:0:7
>
> 1436123254: Sending PUBLISH to fe80::c30c:0:0:7 (d0, q2, r0, m3,
> 'test', ... (1 bytes))
>
> // **PROBLEM HERE** THIS PUBLISH HAS NOT BEEN RECEIBED BUT NOT ACKED!
> 1436123256: Received PUBLISH from fe80::c30c:0:0:7 (d0, q2, r0, m3,
> 'testout', ... (14 bytes))
>
> // RETRYING PUBLISHING  M3 TO fe80::c30c:0:0:7
> 1436123275: Sending PUBLISH to fe80::c30c:0:0:7 (d1, q2, r0, m3,
> 'test', ... (1 bytes))
> 1436123276: Received PUBREC from fe80::c30c:0:0:7 (Mid: 3)
> 1436123276: Sending PUBREL to fe80::c30c:0:0:7 (Mid: 3)
> 1436123277: Received PUBCOMP from fe80::c30c:0:0:7 (Mid: 3)
> ```
>
>
> --
> Skype: felipeanl
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev


Back to the top