Skip to content

Any way to ignore only “connection reset by peer” IOExceptions

I am getting really annoyed with loads of IOExceptions from socket read calls due to network problems. Normally it simply means someone killed the child process or the network went down badly (VPN connection dropped etc).

My server cannot do anything but I really dont want to see all these errors in the log files. Is there any way in java to ignore these exceptions?

I know at the Windows msdn level its a WSAENETRESET error so why do all errors get handled into a generic IOException and not an ConnectionResetException.

Having a connection reset by peer is something which is very generic and standard.

I cant find out if the exception message will appear localised on different Windows OS locales either.



You could use the getMessage() method to see if the exception message is something of the sort:

Connection reset by peer

This should not return a localized version of the error message. That seems to be done by the getLocalizedMessage().

6 People found this is helpful