Strict mode: Untagged network socket
See original GitHub issueDescribe the bug The underlying network socket managed by OkHttp isn’t tagged according to policy. Strict mode complains about it. While it’s a longstanding OkHttp issue other libraries apply a fixed tag.
To Reproduce Enable strict mode in an app’s Application class during onCreate():
if (BuildConfig.DEBUG) {
StrictMode.enableDefaults()
}
Expected behavior A clear and concise description of what you expected to happen.
Logs/Screenshots
2019-08-19 16:00:08.151 17277-17363/foo D/StrictMode: 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:2023)
at com.android.server.NetworkManagementSocketTagger.tag(NetworkManagementSocketTagger.java:82)
...
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:245)
...
Library version 0.6.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
StrictMode java.lang.Throwable: Untagged socket detected
setThreadSocketTag () to track all network usage at android.os.StrictMode.onUntaggedSocket(StrictMode.java:2124) at com.android.server.
Read more >Android O StrictMode: Untagged socket detected #3537 - GitHub
Throwable: Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage at android.os.StrictMode.
Read more >UntaggedSocketViolation - Android Developers
android.os.strictmode.Violation. ↳, android.os.strictmode.UntaggedSocketViolation. Summary. Inherited methods. From class android.os.strictmode.Violation ...
Read more >core/java/android/os/strictmode/UntaggedSocketViolation.java
package android.os.strictmode;. public final class UntaggedSocketViolation extends Violation {. /** @hide */ ... + "track all network usage");.
Read more >Loading Error "Could not connect with Form Server" on ...
UntaggedSocketViolation : Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage at android.os.StrictMode ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately, I don’t think there’s a way to show a message for this issue without requiring the user to install a custom socket factory. I’m going to close this issue for the moment + post the work-around as applied to Coil. If we get duplicate Github issues, we can point users back to this thread.
Here’s the suggested work-around applied to Coil:
See https://stackoverflow.com/a/36840978/2425851 By this answer we need also before
TrafficStats.tagSocket(socket)
callTrafficStats.setThreadStatsTag
. And calluntagSocket
after transfer of dataHow to make it with Coil?