Using modifications behind the proxy server

I am trying to call a Restful service using Retrofit due to a proxy server. Do I need to set proxy server settings to β€œRetrofit” in the code?

+7
java rest retrofit
source share
2 answers

The upgrade does not have parameters to configure any network-related settings. You need to install a proxy server for your Retrofit http client.

Install Proxy on OkHttpClient using setProxy(proxy)

+7
source share

Convert Nicola's words to code:

 java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); OkHttpClient client = new OkHttpClient.Builder().proxy(proxy).build(); Retrofit.Builder builder = new Retrofit.Builder().client(client); Retrofit retrofit = builder.build(); 
+11
source share

All Articles