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

StrictMode violation due to "Untagged socket detected" #59

Open
perracodex opened this issue Jun 29, 2020 · 6 comments
Open

StrictMode violation due to "Untagged socket detected" #59

perracodex opened this issue Jun 29, 2020 · 6 comments

Comments

@perracodex
Copy link

We are getting a StrictMode violation. I've tried to ignore it by setting permitNetwork(), yet still failing.
We can't ignore this issue as we use a penaltyDeath in our StrictMode configuration.

StrictMode policy violation: android.os.strictmode.UntaggedSocketViolation: Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage
        at android.os.StrictMode.onUntaggedSocket(StrictMode.java:2042)
        at com.android.server.NetworkManagementSocketTagger.tag(NetworkManagementSocketTagger.java:98)
        at libcore.io.BlockGuardOs.tagSocket(BlockGuardOs.java:50)
        at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:313)
        at libcore.io.IoBridge.socket(IoBridge.java:640)
        at java.net.PlainSocketImpl.socketCreate(PlainSocketImpl.java:124)
        at java.net.AbstractPlainSocketImpl.create(AbstractPlainSocketImpl.java:128)
        at java.net.Socket.createImpl(Socket.java:489)
        at java.net.Socket.getImpl(Socket.java:552)
        at java.net.Socket.setSoTimeout(Socket.java:1180)
        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:139)
        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)
        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:26)
        at com.giphy.sdk.ui.r$b.call(Unknown Source:202)
        at com.giphy.sdk.ui.t$b.run(Unknown Source:6)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:784)
2020-06-29 22:24:52.797 29477-30125/com.perracolabs.test W/System.err: StrictMode VmPolicy violation with POLICY_DEATH; shutting down.
2020-06-29 22:24:52.797 29477-30125/com.perracolabs.test I/Process: Sending signal. PID: 29477 SIG: 9

@ALexanderLonsky
Copy link
Collaborator

@perracolabs yes, this one is due to okhttp.
I'll be looking into that.

@perracodex
Copy link
Author

Regarding this issue, I've found that it was reported in the okhttp repository.

See issue : square/okhttp#3537

Someone in the thread suggested next as a solution:

https://stackoverflow.com/questions/47723973/strictmode-java-lang-throwable-untagged-socket-detected/57963770#57963770

@ALexanderLonsky
Copy link
Collaborator

Thank you! I'll take a look

@ALexanderLonsky
Copy link
Collaborator

Hey @perracolabs,
are you still facing this issue in the latest version?

@perracodex
Copy link
Author

Yes still happens. I'm with version 2.1.17

To solve the issue the library in Giphy which uses okhttp (I assume is actually fresco), needs to set the threat stats tag, otherwise the problem will always exist.

See issue : square/okhttp#3537

@ALexanderLonsky
Copy link
Collaborator

Thank you for the quick reply!
Yes, this is Fresco that uses okhttp. I updated it in the latest release and was not able to reproduce the issue on my end, but now I see it did not help.

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

2 participants