question-mark
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.

Can't create session when the connection is closing

See original GitHub issue

While receiving events using Event Processor Host, from time to time, I’m getting partition receiver exceptions:

System.InvalidOperationException: Can't create session when the connection is closing. at Microsoft.Azure.Amqp.AmqpConnection.AddSession(AmqpSession session, Nullable1 channel) at Microsoft.Azure.Amqp.AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult.GetAsyncSteps()+MoveNext() — End of stack trace from previous location where exception was thrown — at Microsoft.Azure.Amqp.AsyncResult.End[TAsyncResult](IAsyncResult result) at Microsoft.Azure.Amqp.AmqpCbsLink.EndCreateCbsLink(IAsyncResult result) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) — End of stack trace from previous location where exception was thrown — at Microsoft.Azure.Amqp.FaultTolerantAmqpObject1.OnCreateAsync(TimeSpan timeout) at Microsoft.Azure.Amqp.Singleton1.GetOrCreateAsync(TimeSpan timeout) at Microsoft.Azure.Amqp.Singleton1.GetOrCreateAsync(TimeSpan timeout) at Microsoft.Azure.Amqp.TaskHelpers.EndAsyncResult(IAsyncResult asyncResult) at Microsoft.Azure.Amqp.IteratorAsyncResult1.StepCallback(IAsyncResult result) — End of stack trace from previous location where exception was thrown — at Microsoft.Azure.Amqp.AsyncResult.End[TAsyncResult](IAsyncResult result) at Microsoft.Azure.Amqp.AmqpCbsLink.<>c__DisplayClass4_0.<SendTokenAsync>b__1(IAsyncResult a) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) — End of stack trace from previous location where exception was thrown — at Microsoft.Azure.EventHubs.Amqp.AmqpPartitionReceiver.CreateLinkAsync(TimeSpan timeout) at Microsoft.Azure.Amqp.FaultTolerantAmqpObject1.OnCreateAsync(TimeSpan timeout) at Microsoft.Azure.Amqp.Singleton1.GetOrCreateAsync(TimeSpan timeout) at Microsoft.Azure.Amqp.Singleton1.GetOrCreateAsync(TimeSpan timeout) at Microsoft.Azure.EventHubs.Amqp.AmqpPartitionReceiver.OnReceiveAsync(Int32 maxMessageCount, TimeSpan waitTime) at Microsoft.Azure.EventHubs.Amqp.AmqpPartitionReceiver.OnReceiveAsync(Int32 maxMessageCount, TimeSpan waitTime) at Microsoft.Azure.EventHubs.PartitionReceiver.ReceiveAsync(Int32 maxMessageCount, TimeSpan waitTime) at Microsoft.Azure.EventHubs.Amqp.AmqpPartitionReceiver.ReceivePumpAsync(CancellationToken cancellationToken, Boolean invokeWhenNoEvents)

There is an open issue related to this in azure-amqp sdk github repo https://github.com/Azure/azure-amqp/issues/140), but one of the team members is suggesting that:

This exception is expected when a session is to be created but the connection is closing. Typically the session creation is a result of an API call from the upper SDK and should be handled by the SDK as a communication error. Please report the error to the SDKs you are using so it can be handled correctly by the retry policy in the SDKs.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:34 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
serkantkaracacommented, Oct 27, 2020

Fix will ship in 4.3.1 release soon.

1reaction
serkantkaracacommented, Oct 14, 2020

I have sent a PR to convert this exception to retriable error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MT on Azure Service Bus. Why am I seeing System. ...
MT on Azure Service Bus. Why am I seeing System.InvalidOperationException: Can't create session when the connection is closing? Ask Question.
Read more >
Can't create session when the connection is closing
This exception is expected when a session is to be created but the connection is closing. Typically the session creation is a result...
Read more >
Telnet session already in use, Unable to create session
I have created a telnet session and without exiting properly I closed terminal window. Now I am unable to connect again and can...
Read more >
Troubleshoot AMQP errors in Azure Service Bus
Link is closed ; Connection is closed; Link isn't created; Next steps. This article provides some of the errors you receive when using...
Read more >
Connection (Java EE 6 )
Closing a connection does NOT force an acknowledgment of client-acknowledged sessions. Invoking the acknowledge method of a received message from a closed ...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found