Ihor Yutin
Ihor Yutin

Reputation: 1

Jetty httpclient add proxy socks4

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);
}

Upvotes: 0

Views: 217

Answers (1)

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49515

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.

Upvotes: 0

Related Questions