Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception java.util.NoSuchElementException: socks when making https request with socks5 proxy #1913

Open
Fallen-Breath opened this issue Oct 28, 2023 · 2 comments
Assignees
Labels

Comments

@Fallen-Breath
Copy link

To reproduce

package me.fallenbreath.playground;

import org.asynchttpclient.proxy.ProxyType;

import static org.asynchttpclient.Dsl.*;

public class Main
{
	public static void main(String[] args) throws Exception
	{
		var proxyServer = proxyServer("127.0.0.1", 1081).
				setProxyType(ProxyType.SOCKS_V5);

		try (var client = asyncHttpClient(config().setProxyServer(proxyServer)))
		{
			var response = client.prepareGet("https://cloudflare.com/cdn-cgi/trace").execute().get();
			System.out.println(response);
		}
	}
}

Exception:

Exception in thread "main" java.util.concurrent.ExecutionException: java.net.ConnectException: socks
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
	at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:210)
	at me.fallenbreath.playground.Main.main(Main.java:16)
Caused by: java.net.ConnectException: socks
	at org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:173)
	at org.asynchttpclient.netty.channel.NettyConnectListener.onSuccess(NettyConnectListener.java:109)
	at org.asynchttpclient.netty.channel.NettyChannelConnector$1.onSuccess(NettyChannelConnector.java:91)
	at org.asynchttpclient.netty.SimpleChannelFutureListener.operationComplete(SimpleChannelFutureListener.java:28)
	at org.asynchttpclient.netty.SimpleChannelFutureListener.operationComplete(SimpleChannelFutureListener.java:22)
	at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:590)
	at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:583)
	at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:559)
	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:492)
	at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:636)
	at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:625)
	at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:105)
	at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:84)
	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:300)
	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:335)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.util.NoSuchElementException: socks
	at io.netty.channel.DefaultChannelPipeline.getContextOrDie(DefaultChannelPipeline.java:1073)
	at io.netty.channel.DefaultChannelPipeline.addAfter(DefaultChannelPipeline.java:302)
	at io.netty.channel.DefaultChannelPipeline.addAfter(DefaultChannelPipeline.java:290)
	at org.asynchttpclient.netty.channel.ChannelManager.addSslHandler(ChannelManager.java:427)
	at org.asynchttpclient.netty.channel.NettyConnectListener.onSuccess(NettyConnectListener.java:107)
	... 21 more

The issue only occurs with socks5 + https. Sock4 is not tested, and http proxy works normally

Environment:

  • Java 11
  • org.asynchttpclient:async-http-client:3.0.0.Beta2
@lakxtxue
Copy link

lakxtxue commented Nov 4, 2023

I have the same problem.

@hyperxpro hyperxpro self-assigned this Nov 11, 2023
@cuicuicuinice
Copy link

难顶,我也遇到了...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants