In a WebView, in our Android app, we are trying to detect that a server can’t be reached. It is working in Chrome on Android but not in a WebView in our Android app.
In Chrome:
- I run our website in Chrome on an Android phone (Nexus 4, Android 5.1.1; Nexus 5x, Android 7.1.2) while on our internal network
- Switch to our guest network, which doesn’t have access to the website server
- Select a link to another page on our server
- In my desktop’s Chrome’s device inspection’s console, I immediately see the
net::ERR_NAME_NOT_RESOLVEDerror and we can display a message to the user.
In a WebView:
- I run our website in a WebView in our Android app
- Switch to the guest network
- Select a link to another page on our server
- Nothing happens for a while (about a minute) and then I see, in my desktop’s Chrome’s device inspection’s console, a
net::ERR_CONNECTION_TIMED_OUTerror for the https:// request for the next page. - This is not consistent behavior but it fails in this manner around 75% of the time
I’m trying to understand why Chrome tried to resolve the server’s name but the WebView did not so we then have to wait for the connection to timeout and then display a message to the user?