I get this exception on Android using SocketIo, everytime when internet gets disconnected (I turn off wifi). I cant find the reason, please help :
-
And what, exactly, is the question? – greeble31 Oct 26 '19 at 22:31
-
how to get rid of this exception. what is causing it. – M. Usman Khan Oct 28 '19 at 17:40
1 Answers
This is exception is to be expected any time an SSLSocket
read fails due to an unavailable network. Socket.IO clients may safely ignore it.
As you might expect, disabling a network while you are using it causes I/O errors. In Java, this produces an IOException
of one kind or another. If you had been using "normal" sockets, this would have been a SocketException
, and you would have seen the same sort of message ("software caused connection abort"). Since, in this case, you are using an HTTPS connection, the IOException
is an SSLException
(which wraps the error encountered by the lower-level TCP socket).
Any IOExceptions
thrown by the TCP socket will cause SSLExceptions
on the SSLSocket
, at least until such time as the SSLSocket
is properly closed.

- 4,894
- 2
- 16
- 30
-
Cant ignore this. When i get this exception, my socket shuts down and i need to re-initiate and connect this socket. – M. Usman Khan Oct 29 '19 at 06:30
-
Yes, it might not've been clear from my answer, but this socket is definitely done; the connection is over. After all, you have removed the network! I simply meant that you didn't have to take any special action; it's like any other `IOException` received on a socket. To continue transferring data, you will have to re-establish the connection; there is no getting around that. Note that Socket.IO does this for you, automatically, by default (ref. `IO.Options.reconnection`). If you are having problems with this, you should edit your question to clarify. – greeble31 Oct 29 '19 at 12:53