The link handle '1' cannot be found in session '0'.
masaab opened this issue · comments
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;
}
}
Please enable the frame logging and share the output (after removing password).
Please re-open when frame level logging is available.