Skip to content

Producer DisposeAsync blocks indefinitely when no longer connected #270

@chriscameron-vertexinc

Description

@chriscameron-vertexinc

Hello!

I've identified a problem in my application where when I try to dispose disconnected producers my thread will block forever.

Whenever I attempt to publish a message I first lazy load a producer. I have code that looks something like:

// Is the existing producer good?
if (await producer.IsConnected())
    return producer;

// Dispose the dead producer
await producer.DisposeAsync();

// Create a new producer
return await CreateProducerAsync();

I'm running the official Pulsar Docker image and successfully publishing messages to it. If I restart the container, breaking the connection, my application will hit the DisposeAsync() and block forever.

Looking at the dispose method for ProducerImpl it looks like it doesn't really do anything if the connection state is closed. https://github.com/fsprojects/pulsar-client-dotnet/blob/develop/src/Pulsar.Client/Internal/ProducerImpl.fs#L935

As a workaround I'm simply not disposing my producers if they're no longer connected anymore. Is this safe?

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