-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. #26380
Comments
Hi @xbaha. Thank you for reaching out and we regret that you're experiencing difficulties. From the From context, I'm not exactly sure what behavior you're observing. If you're seeing something that implies that retries are not taking place, it would be helpful to see the exception that is surfacing to your code, including type, message, and the full stack trace. If you're looking for advice on how you could handle exceptions are recover beyond the configured retries, would you please share your scenario and how you're using the SDK? |
Hello, I know for a fact that this error happens due to network problems from my end, like packet loss or DNS failure, but in no way it lasted 24 hours because sometimes it takes a few minutes after running the application for this exception to happen. usually, the type is SocketException, with different messages each time. Call Stack:
Output window: |
Thanks for the additional information. You mention that you're "creating 10 processors" - which I'm assuming means either a Forgive me, but I'm still not clear on what our end-to-end scenario is. Can you help me understand:
If you're able to provide some code snippets that demonstrate your usage or a self-contained repro, that would be ideal. |
Hello,
I apologize for not being clear, by processors I meant Queues, like this one:
public ServiceBusProcessor Sellersprocessor;
Sellersprocessor = client.CreateProcessor(AzureSB.Sellers, messageHandlerOptions);
Sellersprocessor.ProcessMessageAsync += SellersMessageHandler;
Sellersprocessor.ProcessErrorAsync += SellersErrorHandler;
await Sellersprocessor.StartProcessingAsync();
but only 1 ServiceBusClient.
As for the application it’s a WinForm application with simple interface, it does access and pull data from an amazon api 24/7, at the same time, it waits for any messages that might be received from a webapp, the webapp, which is used by our users, can send messages through AMSB to the application when a user changes something in a database table.
I am using AMSB so that the application keeps tracking of the shared database tables that was changed from the webapp without the need to read again from the SQL database for performance purposes.
Finally, When the error happens, Visual Studio throws this error, and the application stops even if I tried to continue.
UPDATE:
After receiving this error many times, I decided to separate AMSB into its own project and reference it back to the other projects in the solution.
Not sure if it helps, so I’ll wait and see.
Regards.
|
That's an interesting statement. That would seem to imply that you're running in Visual Studio with a debugger attached. That results in the debugger observing all exceptions - not just those that would surface to your application - and acting on them based on your debugging configuration in Visual Studio. (more information can be found in the docs) This isn't going to give you a real-world view of how your application behaves, particularly in error scenarios. You'll want to build your application and run on its own, without Visual Studio or any other debugger involved, in order to test its resilience and validate recovery behavior. |
@jsquire Yes, but this should not be the normal behavior, I am unable to continue my application, why does this exception cause the application to stop? |
@xbaha: I'm sorry that we haven't been able to address your concerns. I'm still not clear if you're seeing the same behavior when running the application normally or only when you're running in Visual Studio and/or under a debugger. If you are seeing the processor fail and crash your application, I'd very much like to understand how to reproduce so that we can troubleshoot. Thus far, we have not been able to do so and have observed the processor recovering as expected after restoring network connectivity. If you're able to provide a small repro or additional code snippets that demonstrate your application's use, it would be very helpful and appreciated.
The retry policy will be applied for an operation when an exception is observed. Exceptions are not surfaced to the application until all retries are exhausted. However, a debugger will still observe the exception and may surface it to you despite it being handled. This will depend on your debugger configuration and is beyond the influence of the client. For this reason, to assist, we really need to understand if you're observing these exceptions only when running under Visual Studio or also when your application is running stand-alone.
Agreed. Without understanding more about the context when you're observing the behavior, there's not much insight that I can offer.
This would be the result of your configured |
Hello, so I was able to reproduce the error easily, so here is what I did:
my code:
|
Hi @xbaha. Thank you for confirming. Given your statement in point 3 above, it would seem that what you're describing is correct behavior; the loss of network connectivity is causing errors when attempting service operations which are handled by the SDK and retried until connectivity is restored or the application requests that the processor stop. When the debugger is attached, it injects itself into the runtime and intercepts all exceptions - whether handled or not - and decides what action to take. In your scenario, it would appear that the debugger is configured to capture all first-chance exceptions and control is not being returned to the processor in the correct state for it to continue. This is exacerbated by the artificial delay that a debugger break introduces, as network communication is timeout-based, and the debugging delay will sometimes cause cascading failures due to the allowable time interval being used up. Unfortunately, this isn't something that the SDK can directly influence, and we cannot guarantee that you won't see different and potentially unwanted behavior in cases such as this when the debugger is attached. You may want to explore setting options like "Just My Code" and unsetting options like "Unwind the call stack on unhandled exceptions". The article Manage exceptions with the debugger in Visual Studio may help with discovering and tuning the options to best meet your needs. |
Hi @xbaha. 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 “ |
Hello @jsquire |
Hello, Sorry, in my previous message i had to uncheck the exception itself and leave continue, I did the same for all the exceptions that came when the connection is lost, and it seems it's not throwing any exception. |
Library name and version
Azure.Messaging.ServiceBus 7.4.0
Describe the bug
Sometimes if my connection goes off, i receive this error.I
Output:
Trace:
Expected behavior
I want it to keep trying until it gains the connection back, but the application stops. I added this:
Actual behavior
Would like to find a way to keep trying to gain the connection back without any exception, or at least I can handle the exception.
Reproduction Steps
It's random, sometimes if my connection to the internet is off for just 2-3 minutes, I get this exception, sometimes if I put the connection off for hours, I get no expectation at all.
Environment
Windows 10
The text was updated successfully, but these errors were encountered: