Coder Social home page Coder Social logo

Comments (17)

fingertricks avatar fingertricks commented on April 28, 2024

You need to pass the client (with interceptors) into the RestAdapter Builder:
setClient(new OkClient(okHttpClient))
should read:
setClient(client)

from stetho.

antonkrasov avatar antonkrasov commented on April 28, 2024

@fingertricks, that's exactly how it works. I just use dagger, so client just returned from @provides method. And Injects as okHttpClient.
I can't use setClient(client), as Retrofit requires OkClient, inside it I can pass my custom OkHttpClient.

from stetho.

jasta avatar jasta commented on April 28, 2024

Are you using Retrofit <= 1.8? According to
https://github.com/square/okhttp/wiki/Interceptors, it won't work on that older version without some additional effort.

from stetho.

Tremelune avatar Tremelune commented on April 28, 2024

The Interceptors he is using were not available in Retrofit 1.8.

I'm having the same issue. In the logs I see:

W/System.err﹕ java.io.IOException: Address already in use
W/System.err﹕ at android.net.LocalSocketImpl.bindLocal(Native Method)
W/System.err﹕ at android.net.LocalSocketImpl.bind(LocalSocketImpl.java:303)
W/System.err﹕ at android.net.LocalServerSocket.(LocalServerSocket.java:52)
W/System.err﹕ at com.facebook.stetho.server.LocalSocketHttpServer.bindToSocket(LocalSocketHttpServer.java:278)
W/System.err﹕ at com.facebook.stetho.server.LocalSocketHttpServer.listenOnAddress(LocalSocketHttpServer.java:138)
W/System.err﹕ at com.facebook.stetho.server.LocalSocketHttpServer.run(LocalSocketHttpServer.java:134)
W/System.err﹕ at com.facebook.stetho.Stetho$1.run(Stetho.java:80)
E/stetho﹕ Could not bind to socket.

from stetho.

jasta avatar jasta commented on April 28, 2024

@antonkrasov let me spin up a quick Retrofit 1.9 + OkHttp 2.2.0 sample app to see if I can debug through the problems locally.

@Tremelune that error is unrelated (but still a bug). It's a harmless issue but is unintentionally noisy. I'll fix it soon.

from stetho.

antonkrasov avatar antonkrasov commented on April 28, 2024

@jasta wow, thanks! I really forgot to update Retrofit, updated OkHttp to 2.2.0, but continue using Retrofit 1.7.0

from stetho.

Tremelune avatar Tremelune commented on April 28, 2024

Same issue, with OkHttp 2.2.0 and Retrofit 1.9.

from stetho.

antonkrasov avatar antonkrasov commented on April 28, 2024

@Tremelune, seems like I need to reopen then.

from stetho.

jasta avatar jasta commented on April 28, 2024

@Tremelune I tested this locally and cannot see an issue with Retrofit 1.9. Can you try adding the logging interceptor mentioned in https://github.com/square/okhttp/wiki/Interceptors. I'm curious if that is working. If no, I think your issue is just with interceptors in general.

from stetho.

Tremelune avatar Tremelune commented on April 28, 2024

Yup, I'll see what I can do. I'm hoping for the ol' "clean build" fix...

from stetho.

antonkrasov avatar antonkrasov commented on April 28, 2024

Updating Retrofit to 1.9.0 didn't help, trying to add logging interceptor.

from stetho.

antonkrasov avatar antonkrasov commented on April 28, 2024

@jasta LoggingInterceptor from https://github.com/square/okhttp/wiki/Interceptors works fine for me. But Network tab still doesn't show anything.

from stetho.

jasta avatar jasta commented on April 28, 2024

I confirmed my sample app is working correctly with Retrofit 1.9 and OkHttp 2.2.0. Source is here: https://github.com/jasta/retrofit-okhttp-stetho-demo

Here's the modified GitHubClient: https://github.com/jasta/retrofit-okhttp-stetho-demo/blob/master/app/src/main/java/com/example/retrofit/GitHubClient.java

Screenshot to prove it :)
retrofit

from stetho.

antonkrasov avatar antonkrasov commented on April 28, 2024

@jasta cloning your demo app :) will check it now

from stetho.

antonkrasov avatar antonkrasov commented on April 28, 2024

@jasta yeah, your demo app works for me. Hmm, let me compare with my project and try to find the reason.

from stetho.

antonkrasov avatar antonkrasov commented on April 28, 2024

@jasta Wooohoo, thank you :) I found the issue, and it's quite simple: Proguard.

I fixed this for my project by adding:

-keep class com.facebook.stetho.**{ *; }

from stetho.

vandyshev avatar vandyshev commented on April 28, 2024
W/System.errjava.io.IOException: Address already in use
W/System.errat android.net.LocalSocketImpl.bindLocal(Native Method)
W/System.errat android.net.LocalSocketImpl.bind(LocalSocketImpl.java:254)
W/System.errat android.net.LocalServerSocket.<init>(LocalServerSocket.java:52)
W/System.errat com.facebook.stetho.server.LocalSocketHttpServer.bindToSocket(LocalSocketHttpServer.java:278)
W/System.errat com.facebook.stetho.server.LocalSocketHttpServer.listenOnAddress(LocalSocketHttpServer.java:138)
W/System.errat com.facebook.stetho.server.LocalSocketHttpServer.run(LocalSocketHttpServer.java:134)
W/System.errat com.facebook.stetho.Stetho$1.run(Stetho.java:80)

Just run https://github.com/jasta/retrofit-okhttp-stetho-demo

from stetho.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.