Jetty httpclient add proxy socks4

166 Views Asked by At

When i'm trying to send request via jetty httpClient with new Socks4Proxy(socksHost, socksPort); received: java.util.concurrent.ExecutionException: java.io.IOException: SOCKS4 tunnel failed with code 91

HttpClient httpClient = new HttpClient();
ProxyConfiguration proxyConfig = httpClient.getProxyConfiguration();
Socks4Proxy proxy = new Socks4Proxy(socksHost, socksPort);
proxyConfig.getProxies().add(proxy);

httpClient.start();

String url = config.getProperty(stringUrl);
Request request = httpClient.newRequest(url);
request.method(HttpMethod.GET);
request.onResponseContent(new BufferingResponseListener() {
    @Override
    public void onComplete(Result result) {
        String s = getContentAsString();
        logger.debug("Received http response message: '{}', status: '{}'", s, result.getResponse().getReason());
    }
});

try {
    request.send();
} catch (Exception e) {
    throw new RuntimeException(e);
}
1

There are 1 best solutions below

0
Joakim Erdfelt On

Per https://www.openssh.com/txt/socks4.protocol

Your 91 status means that request was rejected or failed. The user or source program is not authorized to access the proxy server.

Perhaps your SOCKS4 proxy has an authentication requirement.