rabbitmq / rabbitmq-dotnet-client

RabbitMQ .NET client for .NET Standard 2.0+ and .NET 4.6.2+
https://www.rabbitmq.com/dotnet.html
Other
2.05k stars 575 forks source link

Add a test that closes a connection with Toxiproxy #1522

Closed lukebakken closed 2 months ago

lukebakken commented 3 months ago

Follow-up / replacement to #1519

michaelklishin commented 3 months ago

Yay! Bunny has been using a Toxiproxy suite for years (optionally, closing connections over the HTTP API is enough for many recovery tests). It's very useful.

lukebakken commented 3 months ago

@michaelklishin yes, in #1519 I tried to get to the bottom of a strange issue (.NET not getting an end-of-stream when toxiproxy closes the TCP connection) and decided to re-start here.

lukebakken commented 3 months ago

@michaelklishin it turns out toxiproxy uncovered a specific scenario - what happens when you publish a message and the connection is closed before your library receives the basic.ack?

This library does the correct thing when WaitForConfirmsAsync() is used - it raises an exception when the channel is closed. But, my test code wasn't handling the exception, which made it appear as though the connection wasn't being recovered, and the test would timeout. By handling this case correctly in the test, everything is working fine. Whew!