Describe the bug
We are experiencing a reconnection loop due to an unhandled System.ObjectDisposedException on SslStream in our application, using the latest Pulsar.Client (3.16.0), .NET 10, and official ASP.NET 10 Docker base images. This appears to leave the application stuck in a reconnection cycle instead of recovering or failing gracefully.
Exception details
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Security.SslStream'.
at System.Net.Security.SslStream.<ThrowIfExceptional>g__ThrowExceptional|131_0(ExceptionDispatchInfo e)
at Pipelines.Sockets.Unofficial.StreamConnection.AsyncStreamPipe.CopyFromWritePipeToStream()
at System.IO.Pipelines.PipeWriter.CopyFromAsync(Stream source, CancellationToken cancellationToken)
at Pulsar.Client.Common.Commands.serializeSimpleCommand@44-1.MoveNext()
at <StartupCode$Pulsar-Client>.$ClientCnx.clo@302-10.MoveNext()
Environment:
- .NET 10
- Pulsar.Client 3.16.0
- Official ASP.NET 10 Docker image
Observed behavior
- The connection drops, triggering a reconnect loop.
- The reconnect logic appears to run repeatedly (see
ConnectionHandler.fs, ConnectionPool.fs, ClientCnx.fs), but we never recover nor get a permanent failure.
- Exception is thrown in the context of SslStream/Pipelines, possibly after dispose.
Relevant code (semantic search references):
Possible cause
- The reconnect logic with SslStream/Sockets appears to trigger after an ObjectDisposedException that isn't fully handled, leading to continuous attempts.
- See dotnet/runtime #103499 for background around SslStream behavior on disconnection.
Expected behavior
- Client should either recover, or escalate to a permanent failure instead of looping on reconnect when SslStream is disposed.
Steps to reproduce
- Deploy an application using ASP.NET 10 and Pulsar.Client 3.16.0.
- Disrupt broker connection so SslStream gets disposed (e.g., network drop or broker shutdown).
- Observe client logs for reconnect loop with ObjectDisposedException.
Describe the bug
We are experiencing a reconnection loop due to an unhandled
System.ObjectDisposedExceptiononSslStreamin our application, using the latestPulsar.Client(3.16.0), .NET 10, and official ASP.NET 10 Docker base images. This appears to leave the application stuck in a reconnection cycle instead of recovering or failing gracefully.Exception details
Environment:
Observed behavior
ConnectionHandler.fs,ConnectionPool.fs,ClientCnx.fs), but we never recover nor get a permanent failure.Relevant code (semantic search references):
Possible cause
Expected behavior
Steps to reproduce