Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android O StrictMode: Untagged socket detected #150

Open
XDex opened this issue Mar 20, 2018 · 3 comments
Open

Android O StrictMode: Untagged socket detected #150

XDex opened this issue Mar 20, 2018 · 3 comments

Comments

@XDex
Copy link

XDex commented Mar 20, 2018

Running into the same issue as reported in OkHttp with Android O default StrictMode enabled (StrictMode.enableDefaults())..

java.lang.Throwable: Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage
                                                                        at android.os.StrictMode.onUntaggedSocket(StrictMode.java:2010)
                                                                        at com.android.server.NetworkManagementSocketTagger.tag(NetworkManagementSocketTagger.java:78)
                                                                        at libcore.io.BlockGuardOs.tagSocket(BlockGuardOs.java:47)
                                                                        at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:310)
                                                                        at libcore.io.IoBridge.socket(IoBridge.java:667)
                                                                        at java.net.PlainSocketImpl.socketCreate(PlainSocketImpl.java:116)
                                                                        at java.net.AbstractPlainSocketImpl.create(AbstractPlainSocketImpl.java:98)
                                                                        at java.net.Socket.createImpl(Socket.java:484)
                                                                        at java.net.Socket.connect(Socket.java:614)
                                                                        at com.neovisionaries.ws.client.SocketConnector.doConnect(SocketConnector.java:110)
                                                                        at com.neovisionaries.ws.client.SocketConnector.connect(SocketConnector.java:81)
                                                                        at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2022)
                                                                        at io.github.sac.Socket.connect(Socket.java:447)
                                                                        at com.adobe.target.mobile.networking.NaradaClientService$3.run(NaradaClientService.java:253)
                                                                        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                                                                        at java.lang.Thread.run(Thread.java:764)
@TakahikoKawasaki
Copy link
Owner

I'm sorry I don't know technical details about StrictMode. However, if it is an Android-specific issue, nv-websocket-client cannot implement a workaround for the issue internally (unless reflection is used).

WebSocketListener.onThreadCreated() is called between after a thread is created and before the thread's start() method is called. You may be able to write a workaround in the callback method.

@andrew-ld
Copy link

it is not possible to do this because onThreadCreated is not called on the SocketRacer since it does not extend WebSocketThread but uses Thread directly

@andrew-ld
Copy link

andrew-ld commented Sep 16, 2022

andrew-ld@3a8156a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants