You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am seeing NetworkOnMainThreadException when handling close event
10-28 17:12:53.003 20108 20108 E AndroidRuntime: android.os.NetworkOnMainThreadException
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1605)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.Platform.blockGuardOnNetwork(Platform.java:426)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.writeInternal(ConscryptEngineSocket.java:657)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.access$200(ConscryptEngineSocket.java:616)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket.drainOutgoingQueue(ConscryptEngineSocket.java:585)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket.close(ConscryptEngineSocket.java:480)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.close(ConscryptEngineSocket.java:748)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at java.io.BufferedInputStream.close(BufferedInputStream.java:485)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketReader.quit(WebSocketReader.java:130)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketConnection.closeReaderThread(WebSocketConnection.java:259)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketConnection.failConnection(WebSocketConnection.java:300)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketConnection.access$2700(WebSocketConnection.java:60)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketConnection$2.onMessage(WebSocketConnection.java:712)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.utils.AndroidThreadMessenger$1.handleMessage(AndroidThreadMessenger.java:38)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at android.os.Looper.loop(Looper.java:246)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8653)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Is there a reason why "AndroidThreadMessenger" is attached to main looper? Can it be moved to a dedicated thread? I think thats one way this can be fixed.
novak-dev
changed the title
Closing socket on main thread can throw exception on Android
Closing socket on main thread can throw exception on Android 11
Nov 3, 2022
I am seeing NetworkOnMainThreadException when handling close event
10-28 17:12:53.003 20108 20108 E AndroidRuntime: android.os.NetworkOnMainThreadException
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1605)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.Platform.blockGuardOnNetwork(Platform.java:426)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.writeInternal(ConscryptEngineSocket.java:657)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.access$200(ConscryptEngineSocket.java:616)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket.drainOutgoingQueue(ConscryptEngineSocket.java:585)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket.close(ConscryptEngineSocket.java:480)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.close(ConscryptEngineSocket.java:748)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at java.io.BufferedInputStream.close(BufferedInputStream.java:485)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketReader.quit(WebSocketReader.java:130)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketConnection.closeReaderThread(WebSocketConnection.java:259)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketConnection.failConnection(WebSocketConnection.java:300)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketConnection.access$2700(WebSocketConnection.java:60)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.WebSocketConnection$2.onMessage(WebSocketConnection.java:712)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at io.crossbar.autobahn.websocket.utils.AndroidThreadMessenger$1.handleMessage(AndroidThreadMessenger.java:38)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at android.os.Looper.loop(Looper.java:246)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8653)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
10-28 17:12:53.003 20108 20108 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
I found this commit in AOSP Android 11 branch that I believe is the root cause of this:
https://cs.android.com/android/_/android/platform/external/conscrypt/+/9a16085cc2f182bfca9dd6a0d02c82c934887a82
The text was updated successfully, but these errors were encountered: