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

Failing to publish Messages if max_buffered_messages is set to zero #118

Closed
KoWu opened this issue Mar 23, 2021 · 2 comments
Closed

Failing to publish Messages if max_buffered_messages is set to zero #118

KoWu opened this issue Mar 23, 2021 · 2 comments
Labels
fix added A fix was added to an unreleased branch
Milestone

Comments

@KoWu
Copy link

KoWu commented Mar 23, 2021

Creating a client with .max_buffered_messages(0) fails to publish a message with a "Max buffered messages" error, even if a connection is established.

Following code:

let reponse = mqtt_client.connect(conn_options).await.unwrap();
println!("{:?}", reponse);

mqtt_client
    .publish(
        MessageBuilder::new()
            .topic("foo")
            .payload("bar")
            .qos(1)
            .finalize(),
    )
    .await
    .unwrap();

Produces the following log:

20210323 161028.130 3 testclient -> CONNECT version 5 clean: 0 (0)
20210323 161028.168 3 testclient <- CONNACK rc: 0
20210323 161028.168 Cleaning session state on connect because sessionPresent is 0
ServerResponse { rsp: Connect(ConnectResponse { server_uri: "mqtt.example.com:8883", mqtt_version: 5, session_present: false }), props: Properties { cprops: MQTTProperties { count: 2, max_count: 10, length: 6, array: ... } }, reason_code: Success }
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PahoDescr(-12, "Max buffered messages")', src/main.rs:124:10
@fpagliughi fpagliughi added this to the v0.10 milestone Oct 2, 2021
@fpagliughi
Copy link
Contributor

I confirmed this behavior. It's happening in the underlying C library. I created an issue over there to clarify what's happening and how best to handle it:
eclipse-paho/paho.mqtt.c#1193

@fpagliughi
Copy link
Contributor

OK, after testing for a while it really appears that the C client relies on this buffer limit even when the client is connected to the broker. You definitely need at least one slot to even send a message. For sanity sake, internally I'll set a lower limit to make sure you can still send messages while connected if you set this to zero.

But even better than that I expose the ability to enable/disable off-line buffering separate from the size of the buffer. Now there's a CreateOptionsBuilder::send_while_disconnected()

fpagliughi added a commit that referenced this issue Jan 21, 2022
…d_messages(). Added send_while_disconnected()
@fpagliughi fpagliughi added the fix added A fix was added to an unreleased branch label Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix added A fix was added to an unreleased branch
Projects
None yet
Development

No branches or pull requests

2 participants