We are having a problem with our Android app that scans for beacons with Bluetooth, when user is currently using the app. The app is loading data from API when different views are being loaded. Sometimes, when keep on clicking views one request fails (time-out), with this error:
java.net.SocketTimeoutException: failed to connect to www.examplehost.com/111.222.333.444 (port 80) after 15000ms
at libcore.io.IoBridge.connectErrno(IoBridge.java:169)
at libcore.io.IoBridge.connect(IoBridge.java:122)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:452)
at java.net.Socket.connect(Socket.java:884)
at com.android.okhttp.internal.Platform.connectSocket(Platform.java:117)
at com.android.okhttp.internal.http.SocketConnector.connectRawSocket(SocketConnector.java:434)
at com.android.okhttp.internal.http.SocketConnector.connectCleartext(SocketConnector.java:105)
at com.android.okhttp.Connection.connect(Connection.java:1331)
at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:1410)
at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:466)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:447)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:353)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:468)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:410)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:532)
(It is the IP address of our server, replaced it with 111.222.333.444)
It's a time-out (> 15 seconds), while requests before that are rather fast.
I don't experience this problem with other devices, only on Samsung S6 when updated to Android 6.0.1. Because the app is on the foreground, I don't think it could be Doze or Standby (new in Android 6) because the app is being actively used. But the same problem probably occurs when app is in background (but it's difficult to test).
LG Nexus 5
(also with Android 6.0.1) the problem never occurs.Does anybody have an idea where we should look for the problem? Thanks in advance.
While this is the first report I have heard this on the S6, this is a common problem on other devices like the Nexus 4, Nexus 7, Moto G and Moto X. These devices experience interference between the WiFi and Bluetooth radios, which share the same radio frequency bands and in some device models share a chip and antenna. On the Nexus 4 and Moto G, the problem is so bad that streaming music while using a Bluetooth speaker is impossible. So the problem is not specific to beacons.
There is no known workaround, but you can detect the device model, and if it is known to be problematic, prompt the user to turn off WiFi. or even do it for the user (with proper notification, of course.)
It would be interesting to know if the same problem exists on an S6 with an earlier Android version. If so, this suggests a fix may be possible in firmware, for the S6 at least.
Full disclosure: I am the lead developer on the Android Beacon Library open source project.