android maps failing after vpn connection-Collection of common programming errors
I seem to have bumped into an interesting problem that I hope someone else has seen before. I am working on a VPN app and one of the features is a map showing your ip-address location both before and after you connect to the VPN. This requires showing a map both before and after the connection.
Everything works fine, except after I connect to the VPN, when the map updates to the new location, it just stays as gray tiles for about 1 minute before finally downloading the new locations data.
I actually encountered a similar problem with any web-call that I was making both before and after connecting the to VPN, and it turned out the OS was keeping the socket open from the first call and trying to use it again on the second call rather than the vpn tunnel. It would then wait for the second call to timeout and then finally retry and make the connection. I have resolved this issue with
System.setProperty(“http.keepAlive”, “false”);
and setting the timeout term in my httpconnectionparams to only being 2 seconds:
HttpConnectionParams.setSoTimeout(httpParams, 2000);
This seems to have resolved the primary issue of my connections not working, but unfortunately I still have the same problem with the native maps. It seems like when the map gets added, it tries to keep a single socket open the whole time and needs a timeout before it can properly connect to the google servers. Does anyone know how I can force the map connection closed so that it can connect to google’s servers properly through the VPN?
Thanks in advance!!