IBM Java SDK: Configure Proxies for IAM and Service Calls
Set the IAM authenticator's proxy and the service's HttpConfigOptions before either starts making requests.
Set both routes during initialization, using the IAM authenticator actually supplied to the service:
import java.net.InetSocketAddress;
import java.net.Proxy;
import com.ibm.cloud.sdk.core.http.HttpConfigOptions;
var proxy = new Proxy(
Proxy.Type.HTTP,
new InetSocketAddress("proxy.example.net", 8080));
authenticator.setProxy(proxy);
var options = new HttpConfigOptions.Builder()
.proxy(proxy)
.build();
service.configureClient(options);Here authenticator and service are the application's existing objects. Apply the settings before token acquisition or service requests begin, with normal certificate verification enabled. Where the application may use a public HTTP endpoint for both destinations, candidate addresses are available in the HTTP proxy list.
The two assignments cover different requests. authenticator.setProxy covers the IAM token path; service.configureClient applies the proxy to the service transport. Configuring one does not establish the other's route.
For a failure, identify the host named in the failing request. Successful token acquisition narrows the problem to the service path; it does not prove that path received its proxy options.
HttpConfigOptions comes from IBM Java SDK Core. When adapting an old ConversationService example, use the Core package and service generation selected by the application rather than copying an older service-specific networking class.