Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incoming messages only processed when sending messages

See original GitHub issue

I am new to AMQP and amqpnetlite, but have been struggling with some fairly basic functionality. I am trying to implement a basic pub/sub API using AMQP, and I keep having problems with message only being received as part of sending a message, either immediately or after a short delay.

I have boiled it down to a very small example, with a dummy “chat” app, that I have made available here:

The repo includes detailed repro steps, and ready-to-run code, but overall workflow is this:

  var factory = new ConnectionFactory();

  if ( options.Trace ) {
    Trace.TraceLevel = TraceLevel.Frame;
    Trace.TraceListener = ( _, format, objects ) => Console.WriteLine( Format( format, objects ) );

  var connection = await factory.CreateAsync( new Address( options.Uri ) );

  var session = new Session( connection );

  var receiver = new ReceiverLink(
    options.Key );

  var sender = new SenderLink( session, "sender", options.Key );

  void OnMessage( IReceiverLink link, Message message ) {
    Console.WriteLine( $"{DateTime.Now.ToLongTimeString()} > INCOMING:{message.GetBody<string>()}" );
    link.Accept( message );

  receiver.Start( 100, OnMessage );

  while ( true ) {
    Console.WriteLine( "Enter a message, 'exit' to quit" );
    var message = Console.ReadLine();
    if ( IsNullOrWhiteSpace( message ) ) {
      Console.Error.WriteLine( "Try again!" );

    if ( message == "exit" ) {

    await sender.SendAsync( new Message( message ), TimeSpan.FromSeconds( 5 ) );
    Console.WriteLine( $"{DateTime.Now.ToLongTimeString()} > SENT: {message}" );

The behavior I see depends a bit on the broker, but the general pattern is that at some point the client stops receiving incoming messages, but that as soon as the client sends a message, the callback is processed.

My guess is that there is something simple that I missed (and perhaps isn’t documented?) Perhaps related to link credit?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

Havretcommented, Feb 21, 2022

The pump is just while(true) loop statement that’s reading bytes from the socket. If it receives enough data to parse a complete frame it deserializes it and invokes the client-specific code like your OnMessage callback. If you block inside this callback the pump cannot read any new bytes. So your app gets stuck.

The same applies when you are sending a message. When the other side receives it, it sends back ack frame that completes this operation from your POV (again there’s callback that completes TaskCompletionSource). If you run some blocking code as a continuation, you end up with the same problem as above because you’re again blocking the pump.

In my producer example I manually control completion via my own TaskCompletionSource. So I can instruct it to run the continuation on the thread pool and make sure that I don’t block the pump.

I hope that answers your question.

petertiedemanncommented, Feb 24, 2022

@xinchen10 I will close this issue and am just writing up a small PR for the docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Messages is processing an incoming message
While leaving it open, open the Messages app on the problematic phone, go to "Device pairing" and scan the aforementioned QR code.
Read more >
Has anyone even seen this error? 'Messages is processing ...
'Messages is processing an incoming message'. I only found it going through my notifications when I was asked why I hadn't picked up...
Read more >
java - Ensuring ordered processing of messages
In the example below, I have two instances of a service that are processing messages from kafka, but I want to ensure that...
Read more >
Resolving problems when using messages
Check that your sending application is sending only valid data. ... Check that the incoming XML message is being represented by the correct...
Read more >
Receive messages | Business Messages
Handle incoming messages · Acknowledge the message · Verify that the message is from Google · Identify the locale · Route the message...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found