Skip to content

Conversation

@mtmk
Copy link
Member

@mtmk mtmk commented Nov 19, 2025

Put behind an option to not break existing behavior.

@mtmk mtmk requested a review from scottf November 19, 2025 11:14
Copy link
Contributor

@scottf scottf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mtmk mtmk self-assigned this Nov 26, 2025
@mtmk mtmk added the priority label Nov 27, 2025
@mtmk
Copy link
Member Author

mtmk commented Dec 2, 2025

@paagamelo2 does this work for you?

@paagamelo2
Copy link

@paagamelo2 does this work for you?

Apologies, haven't had a chance to try this out yet. Will do between today and tomorrow!

@paagamelo2
Copy link

@mtmk I'm seeing the same behavior as before, despite using the new PublishTimeoutOnDisconnected flag.

I see in your tests you wait for the reconnection loop to kick in, which I don't. The only other difference is that I'm using Testcontainers. I'd be surprised if any of that makes a difference though.

This is essentially what I'm doing:

[Fact]
public async Task ExperimentWithRealNats()
{
    await using var nats = new NatsBuilder().Build();
    await nats.StartAsync();

    await using var client = new NatsClient(nats.GetConnectionString());
    var js = client.CreateJetStreamContext(new NatsJSOpts(new NatsOpts
    {
        CommandTimeout = TimeSpan.FromSeconds(3),
        PublishTimeoutOnDisconnected = true,
    }));

    await js.CreateStreamAsync(new StreamConfig("ORDERS", ["orders.>"]));

    await nats.StopAsync();

    try
    {
        await js.PublishAsync("orders.1", "this is my order :)");
    }
    catch (Exception ex)
    {
        Debugger.Break(); // <- never hit
    }
}

Do you spot anything wrong?

@mtmk
Copy link
Member Author

mtmk commented Dec 4, 2025

Thanks for checking this @paagamelo2

Can you try passing the opts to client:

    await using var client = new NatsClient(new NatsOpts
    {
        Url = nats.GetConnectionString(),
        CommandTimeout = TimeSpan.FromSeconds(3),
        PublishTimeoutOnDisconnected = true,
    });
    var js = client.CreateJetStreamContext();

@paagamelo2
Copy link

@mtmk cheers, that works as expected for me!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants