-
Notifications
You must be signed in to change notification settings - Fork 34
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
Allow SocketException in socket.Endpoint #39
base: master
Are you sure you want to change the base?
Conversation
@reb3lzrr My org just ran into this too. It doesn't happen frequently, but it appears we sometimes get disconnected from the remote endpoint of the Socket. Microsoft docs say "The RemoteEndPoint is set after a call to either Accept or Connect. If you try to access this property earlier, RemoteEndPoint will throw a SocketException." https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.remoteendpoint?view=net-5.0 Then when we try to validate whether we are connected, we hit this exception. The code you have written seems completely fine, since the code only uses those properties in the exception message |
I am not sure how your team gets around this, but currently when this happens we have to restart our application in order to reconnect to the same smb directory. I am going to try using one of these methods from (#24) to try removing that old connection in the mean time. |
Our stack is a follows:
|
Side note: It turns out for our case using SmbTransport.ClearCachedConnections(true); lead to an InvalidOperationException, possibly since it has a foreach over the collection, and then calls to remove it from there. We weren't able to remove the "bad" connection without the force flag set to true.. that means that the problematic SmbTransports believes it has a Socket that is connected
|
For the above mentioned InvalidOperationException, I have created this github issue to track it outside of this one: #40 |
Sorry I didn't have time to get back to you sooner; we choose to abandon this package as it appears that the owners is not maintaining it actively. We used this package in a Kubernetes-hosted AspNetCore 3.1 application. Thanks to kubernetes we could switch to a CIFS-based driver and rely on the IO tools provided by System.IO namespace. I hope this answers your question, |
Apply fix from ume05rw#39
Problem
We've only recently been using the software and this problem popped up multiple times. It appears that an exception occurs while trying to rethrow and handle another exception. This causes the sockets to not be cleaned up properly and (in our case) Tasks to run indefinitely.
Chosen solution
This PR allows the
Socket.RemoteEndPoint
andSocket.LocalEndPoint
properties to throw aSocketException
. I've chosen this solution as it appears that both thelocal
andremote
variable were allowed to benull
Background Info
Below is the stacktrace of the situation as described