-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ServiceBusConnectionError after running idle #36376
Comments
Thank you for your feedback. Tagging and routing to the team member best able to assist. |
Hi @bosegeorge1212 , I am seeing this line in your logs which shows up after retries are done.
It seems like the connection is dropping. Are you able to provide us debug logging with frames turned on please?
import logging
import sys
handler = logging.StreamHandler(stream=sys.stdout)
logger = logging.getLogger('azure.servicebus')
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
...
from azure.servicebus import ServiceBusClient
client = ServiceBusClient(..., logging_enable=True) |
Hi @kashifkhan i have already added it and the above logs are with that. Thanks in advance logger.setLevel(logging.DEBUG)
ServiceBusClient.from_connection_string(conn_str=connection_string, logging_enable=True) |
Hi @bosegeorge1212 - It looks like all retries have been exhausted as per:
The last retry raised an exception due to connection drop as @kashifkhan mentioned, which is expected behavior. By default, the operation is retried 3 times. The first couple of retries are not included in the log snippet above. To confirm that all retries failed due to connection dropping, would you be able to provide logs beginning from before this exception started occurring? If you'd like to modify default retry behavior, you can adjust retry configs, listed [here]. |
Hi @bosegeorge1212. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue. |
Is there any way to identify the root cause of the connection loss? It appears to be a recurring pattern where the connection is lost every 10-15 hours of no messages. We are hosting the application in Azure Container Apps and utilizing a VNET as well. |
@bosegeorge1212 ServiceBusConnectionErrors are caused by transient network issues or service problems. However, this error is not returned by the service, as they would provide more information such as a tracking ID or a message to retry. This is an error raised by the OS to indicate that the connection dropped. Given that it's not able to reconnect on retry, it seems that it was disconnected for a while. Is there other activity happening on your VNET (heavier than usual) that could be causing issues? In order to provide more assistance, we would also need the full logs including all retries. |
Hi @bosegeorge1212. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue. |
@swathipil Is there any other activity happening on your VNET (heavier than usual) that could be causing issues? -> Nothing as far as we know. |
Thanks @bosegeorge1212. We'll investigate and get back to you asap. |
Hi @bosegeorge1212 - I'm currently working on trying to reproduce the connection reset by peer error. In the logs that you provided, has anything been stripped out? More specifically, have any logs been removed between these two lines?
and
I would expect to see logs with the message: "Retrying..". Example of expected logs in the comment below. |
Hi @bosegeorge1212. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue. |
@bosegeorge1212 - While I was not able to trigger a ConnectionResetError, I was able to trigger a ConnectionRefusedError, which follows the same path and raises the same ServiceBusConnectionError. In the logs, I am able to see that the client retried 3 times, as per the default. These are the steps I followed:
You can check that your rule has been added to the iptable by running: And delete a rule with: Logs:
|
We are currently investigating an issue where our application, deployed in Azure Container Apps, experiences intermittent connectivity problems with the Azure Service Bus after 10-20 hours of inactivity. Despite having implemented retry logic, we are keen to identify the root cause of this issue. While we have simulated network issues such as ConnectionRefusedError and ConnectionResetError to test our retry logic, we are now focused on understanding why these errors occur after prolonged periods of inactivity. Given that we do not have access to the underlying VM to perform more granular network testing, we are exploring other methods to pinpoint the cause. Could you please suggest any approaches or tools that could help us diagnose and resolve this issue effectively? |
nothing is missed. adding once more
|
Hi @bosegeorge1212 - The logs show that the SDK raises the error when the OS error occurs. Based on the info you've provided and the repro that I added here, the retry logic in the SDK is working as expected.
FYI: The connection to the service is not meant to stay open for 10-20 hours of inactivity. In general, the service has a [10 minute idle timeout]. Since these connection errors are not from the Service Bus service, we would suggest following the [Container Apps troubleshooting guide] or opening an issue with Container Apps. |
Hi @bosegeorge1212. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation. |
Hi @bosegeorge1212, since you haven’t asked that we |
Describe the bug
We are getting the following error while receiving messages from Service Bus: azure.servicebus.exceptions.ServiceBusConnectionError: Cannot read frame due to exception: [Errno 104] Connection reset by peer. Error condition: amqp:socket-error.
We observe this behavior when there are no messages in the subscription and you keep the app running.
To Reproduce
There are no exact steps to reproduce this issue. It happens inconsistently. We observe this happening when there are no messages in the subscription, and the app has been running for a long duration.
Expected behavior
The SDK should retry with some delay.
Logs
this is the code snippet inside a package
and this is code snippet inside our API that invoke the above
The text was updated successfully, but these errors were encountered: