How to properly handle this exception: System.Net.Sockets.SocketException

,

I’m writing a WPF app using the latest Elements and latest DA beta versions. My DA code uses DALINQ extensively for all data access via a client library DLL accessing Relativity.

All has been going well, but lately this week i have one user who is continually getting the following exception at various places in the application:

System.Net.Sockets.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 

How would you suggest i best handle this exception? I’m suspecting some network issues on her end, but as of yet i haven’t confirmed this. Nobody else is getting this exception when using/testing the application.

This exception could show up anywhere for her, so i’m struggling as to how to best handle it. Any suggestions would be appreciated!

Thanks

Alan,

yes, this is a network connectivity issue (of whatever sort, maybe she has a bad connection. no connection at all, or a bad touting to the server.). This can always happen, and for network IO, you should always expect the possibility that it will fail, and handle it accordingly — e.g. show a network error dialog, and and the user if they want to try again or go into an offline mode (if applicable), and/or , for updates to the server, properly store them in a briefcase for later retry.

For all you known, the user is on a laptop via 3G/LTE and driving into a tunnel.

As marc said, you should always assume that any network operation might fail. Network is not reliable by definition, after all.
Also for really unreliable connections you might consider to downgrade client channel from SuperHTTP to HTTP (if you use SuperHTTP). Note that server SuperHTTP channel can handle plain HTTP requests if the corresponding option is enabled.

1 Like

But is there any general event I could use in my client class lib to centralize any network exception handling? Or should I handle this in the main client app code?

Unfortunately no.

Main issue is that once exception occurs it is not clear how to proceed - should it be a retry attempt or some other recovery procedure should be used.

It is up to you how to handle this. Probably the best option would be to catch exceptions at communication class lib level and re-raise application-specific exceptions and let the main app to handle them.