okHttp fails with retrofit while using vpn
Asked Answered
D

1

6

I've been using my code on my company networks and it works really fine, but when I want to use it from my home (using a vpn to connect to the company network), it fails saying : Unable to resolve host X: No adress associated with hostname.

What is weird is that I actually can use the link in the browser (it works fine). Is there any configuration that I need to add?

            OkHttpClient defaultHttpClient = new OkHttpClient.Builder()
                .addInterceptor(new Interceptor() {
                    @Override
                    public Response intercept(Interceptor.Chain chain) throws IOException {
                        Request authorisedRequest = chain.request().newBuilder()
                                .addHeader("Authorization", TNConstants.BASIC +
                                        Base64.encodeToString((username+ ":" + password).getBytes(), Base64.NO_WRAP)).build();
                        return chain.proceed(authorisedRequest);
                    }}).build();

It actually fails in the chain.proceed(authorisedRequest) function. Please help me with that. Thank you!

Didactic answered 22/11, 2017 at 5:56 Comment(0)
I
0

You may want to try okHttpClient.connectionPool.evictAll() before your request call that may resolve your issue

Isomerism answered 8/12, 2020 at 0:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.