Azure / amqpnetlite

AMQP 1.0 .NET Library
Apache License 2.0
402 stars 145 forks source link

Protocol violation when sending FLOW field delivery-count #578

Closed ansd closed 8 months ago

ansd commented 9 months ago

Issue https://github.com/Azure/amqpnetlite/issues/575 was about field next-incoming-id whereas this issue is about field delivery-count.

AMQP 1.0 section 2.7.4 states for FLOW field delivery-count:

In the event that the receiving link endpoint has not yet seen the initial attach frame from the sender this field MUST NOT be set.

However, this library sets field delivery-count irrespective whether it has received the server's ATTACH frame.

This bug was discovered by @kjnilsson while reviewing https://github.com/rabbitmq/rabbitmq-server/pull/9022

The dotnet client will output the following error:

Unhandled exception. Amqp.AmqpException: There is no credit to accept a new delivery (id=1) on the link.
   at Amqp.ReceiverLink.ReceiveInternal(MessageCallback callback, Int32 timeout)
   at Amqp.ReceiverLink.Receive()
   at Program.Pipe #4 input at line 219@221-2.Invoke(Unit unitVar) in /home/david/workspace/rabbitmq-amqp10-perf/Program.fs:line 221
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncPrimitives.Start@1174-1.Invoke(ExceptionDispatchInfo edi) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1174
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
   at <StartupCode$FSharp-Core>.$Async.clo@193-15.Invoke(Object o) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 195
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

Please let me know if you need more detailed steps on how to reproduce this bug.