How to manage ssl connection when network service changes
I'm playing around with an open source project in hopes that I can offer a
fix for a bug I submitted that's driving me nuts. The short version is
that if change network service, the app dies. This occurs (slightly
differently) when:
I walk from WiFi coverage to 4g or vice-versa
I connect via WiFi with the client and then turn WiFi off, failing over to 4g
I thought the issue might be with the app's isConnected method, which
returns:
return ni != null && ni.isConnected();
Which I updated (in local SDK) to:
return ni != null && ni.isConnectedOrConnecting();
But once I actually switched to hardware device instead of virtual, I now
see the error is with SSL connection. I can't tell if the issue is that
it's running constantly so will always be "interrupted", or if there
should be some sort of try/catch or if the connection simply needs some
mechanism in place to reconnect rather than vomit and pull the app down.
Hoping for a quick fix, I went looking for how SSL is managed/enabled for
a connection, but instead found a lot of frustrated workarounds.
Here is the immediate error in the SDK log.
08-06 03:38:48.795: W/InputEventReceiver(16140): Attempted to finish an
input event but the input event receiver has already been disposed. 08-06
03:38:57.744: W/System.err(16140): javax.net.ssl.SSLException: Read error:
ssl=0x4144cb18: I/O error during system call, Connection timed out 08-06
03:38:57.744: W/System.err(16140): at
org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_read(Native Method)
08-06 03:38:57.744: W/System.err(16140): at
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:651)
What I'm wondering is if there is a prescribed method for handling
non-HTTP SSL/TLS open connections when Network Service switches. I imagine
a new handshake needs to happen, but is there a .isFading() or similar
broadcast info to gracefully hang an app until connection switches or is
officially gone?
No comments:
Post a Comment