Azure / amqpnetlite

AMQP 1.0 .NET Library
Apache License 2.0
401 stars 143 forks source link

The link handle '1' cannot be found in session '0'. #523

Closed masaab closed 2 years ago

masaab commented 2 years ago

My code works fine on the first call but fail with error The link handle '1' cannot be found in session '0'. I have made sure to use async completely. I have currently commented the Accept method as I dont want to keep adding records to the queue. Below is my code.

public async Task<string?> ReceiveSolaceQueueMessages(string host, int port, string path, string username, string password)
        {
            try
            {
                Address address = new Address(host, port, username, password);
                Connection connection = new Connection(address);
                Session session = new Session(connection);

                ReceiverLink receiver = new ReceiverLink(session, "receiver-link", path);
                IList<string> messages = new List<string>();
                receiver.Start(1, async (link, msg) =>
                {
                    var item = await ProcessMessageAsync(link, msg);
                    messages.Add(item);

                });
                receiver.AddClosedCallback((sender, error) => { });

                //Console.WriteLine("Receiver connected to broker.");

                //Message message = await receiver.ReceiveAsync();
                //if (message.Body != null)
                //{
                //    Console.WriteLine("Received " + message.Body);
                //}

                //receiver.Accept(message);
                await receiver.CloseAsync();
                await session.CloseAsync();
                await connection.CloseAsync();

                return await Task.Run(() => JsonConvert.SerializeObject(messages, Formatting.Indented));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
xinchen10 commented 2 years ago

Please enable the frame logging and share the output (after removing password).

xinchen10 commented 2 years ago

Please re-open when frame level logging is available.