Skip to content

[Bug] Producer warns of send timeout when no messages queued up #576

Closed

Description

@meisly

Search before asking

  • I searched in the issues and found nothing similar.

Version

We're using the pulsar-client-node v1.17.0 which uses the pulsar-client-cpp v4.0.1 on Ubuntu 20.04.6

Minimal reproduce step

Create a producer and leave it connected while no messages are being sent to it

What did you expect to see?

I expect it to connect and do nothing

What did you see instead?

It warns of a send timeout every 30 seconds (the default sendTimeoutMs value for the producer) when idle but works without issues when there are messages to be produced. Here is an example of the log warning:

[Wed May 13 2026 20:49:08] WARN: ProducerImpl-874() => [persistent://redacted, clusterName] Send timeout due to queueing delay, connection: [redacted -> redacted] , pending messages: 0, queue size: 0

Anything else?

I suspect that code block that does the timeout logging (shown below) should not be called when the pendingMessageQueue is empty.

    auto cnx = getCnx().lock();
    if (cnx) {
        LOG_WARN(getName() << "Send timeout due to queueing delay, connection: " << cnx->cnxString()
                           << ", pending messages: " << pendingMessages.size()
                           << ", queue size: " << pendingMessagesQueue_.size());
    } else {
        LOG_WARN(getName() << "Send timeout due to queueing delay, no connection, pending messages: "
                           << pendingMessages.size() << ", queue size: " << pendingMessagesQueue_.size());
    }
    for (const auto& op : pendingMessages) {
        op->complete(ResultTimeout, {});
    }
}

Maybe it could be moved to the else block immediately above it (shown below)?

    if (pendingMessagesQueue_.empty()) {
        // If there are no pending messages, reset the timeout to the configured value.
        LOG_DEBUG(getName() << "Producer timeout triggered on empty pending message queue");
        asyncWaitSendTimeout(milliseconds(conf_.getSendTimeout()));
    } else {
        // If there is at least one message, calculate the diff between the message timeout and
        // the current time.
        auto diff = pendingMessagesQueue_.front()->timeout - TimeUtils::now();
        if (toMillis(diff) <= 0) {
            // The diff is less than or equal to zero, meaning that the message has been expired.
            LOG_DEBUG(getName() << "Timer expired. Calling timeout callbacks.");
            pendingMessages = getPendingCallbacksWhenFailed();
            // Since the pending queue is cleared now, set timer to expire after configured value.
            asyncWaitSendTimeout(milliseconds(conf_.getSendTimeout()));
        } else {
            // The diff is greater than zero, set the timeout to the diff value
            LOG_DEBUG(getName() << "Timer hasn't expired yet, setting new timeout " << diff.count());
            asyncWaitSendTimeout(diff);
        }
    }

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. BewareMyPower commented on Jun 1, 2026

    @BewareMyPower
    Contributor

    Good finding! It can be easily reproduced via applying the patch below and running example/SampleProducer:

    diff --git a/examples/SampleProducer.cc b/examples/SampleProducer.cc
    index 0a3c693..d3cd3a7 100644
    --- a/examples/SampleProducer.cc
    +++ b/examples/SampleProducer.cc
    @@ -18,7 +18,9 @@
      */
     #include <pulsar/Client.h>
    
    +#include <chrono>
     #include <iostream>
    +#include <thread>
    
     #include "lib/LogUtils.h"
    
    @@ -29,17 +31,16 @@ using namespace pulsar;
     int main() {
         Client client("pulsar://localhost:6650");
    
    +    ProducerConfiguration conf;
    +    conf.setSendTimeout(100);
         Producer producer;
    -    Result result = client.createProducer("persistent://public/default/my-topic", producer);
    +    Result result = client.createProducer("persistent://public/default/my-topic", conf, producer);
         if (result != ResultOk) {
             LOG_ERROR("Error creating producer: " << result);
             return -1;
         }
    
    -    // Send synchronously
    -    Message msg = MessageBuilder().setContent("content").build();
    -    Result res = producer.send(msg);
    -    LOG_INFO("Message sent: " << res);
    +    std::this_thread::sleep_for(std::chrono::seconds(3));;
    
         client.close();
     }

    Outputs:

    2026-06-01 11:45:30.949 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.050 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.151 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.252 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.353 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.455 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.555 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.656 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.757 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.858 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:31.959 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.060 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.161 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.262 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.363 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.465 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.565 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.666 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.767 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.869 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:32.969 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:33.071 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:33.171 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:33.273 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:33.373 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:33.474 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:33.576 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:33.677 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    2026-06-01 11:45:33.778 WARN  [0x16b743000] ProducerImpl:880 | [persistent://public/default/my-topic, standalone-0-0] Send timeout due to queueing delay, connection: [127.0.0.1:50662 -> 127.0.0.1:6650] , pending messages: 0, queue size: 0
    
  2. BewareMyPower commented on Jun 1, 2026

    @BewareMyPower
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions