-
Bug
-
Resolution: Fixed
-
P4
-
9.0.4
-
x86_64
-
windows
FULL PRODUCT VERSION :
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 10
EXTRA RELEVANT SYSTEM CONFIGURATION :
Fiddler on loop-back port 8888
Shadow-socks on loop-back port 1080
A DESCRIPTION OF THE PROBLEM :
Send request using Https protocol though proxy throws IOException "Tunnel failed"
I have the fiddler software opened, when I tried to send a request to "https://www.google.com" proxy using fiddler, the method throws IOException "Tunnel failed", switching to different HTTPS URI don't help, but it is functioning under HTTP protocol.
I tried to set proxy selector to shadow-socks (a proxy software), it throws the same Exception again.
In fiddler console, it showed fiddler refused that request with statue code 400, message "Fiddler - Bad Request", "[Fiddler] HTTP Request specified an invalid port number."
Request captured by fiddler:
"
CONNECT socket://www.google.com:443/ HTTP/1.1
Content-Length: 0
Host: socket://www.google.com:443/
"
It seems specify default port causes this problem, although there's no specification that specified this, but for compatibility this should be "fix".
The error message should be more than "Tunnel failed" as well
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
launch the fiddler software or some proxy software
construct an HttpClient, version is HTTP_1_1, set ProxySelector to that proxy software
Send a request under HTTPS protocol use that HttpClient
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
200 or some other status code
ACTUAL -
java.io.IOException: Tunnel failed
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.io.IOException: Tunnel failed
at jdk.incubator.httpclient/jdk.incubator.http.PlainTunnelingConnection.connect(PlainTunnelingConnection.java:80)
at jdk.incubator.httpclient/jdk.incubator.http.SSLTunnelConnection.connect(SSLTunnelConnection.java:52)
at jdk.incubator.httpclient/jdk.incubator.http.Http1Exchange.sendHeadersOnly(Http1Exchange.java:136)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl0(Exchange.java:298)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl(Exchange.java:245)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.response(Exchange.java:121)
at jdk.incubator.httpclient/jdk.incubator.http.MultiExchange.response(MultiExchange.java:154)
at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:234)
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
HttpResponse<String> send = HttpClient
.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
// fiddler
.proxy(ProxySelector.of(new InetSocketAddress(InetAddress.getLoopbackAddress(), 8888)))
// shadow-socks
// .proxy(ProxySelector.of(new InetSocketAddress(InetAddress.getLoopbackAddress(), 1080)))
.build()
.send(
HttpRequest
.newBuilder()
.uri(URI.create("https://www.google.com"))
.GET()
.build(),
HttpResponse.BodyHandler.asString()
);
System.out.println(send.statusCode());
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Customize a proxy software that can accept this form of request.
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 10
EXTRA RELEVANT SYSTEM CONFIGURATION :
Fiddler on loop-back port 8888
Shadow-socks on loop-back port 1080
A DESCRIPTION OF THE PROBLEM :
Send request using Https protocol though proxy throws IOException "Tunnel failed"
I have the fiddler software opened, when I tried to send a request to "https://www.google.com" proxy using fiddler, the method throws IOException "Tunnel failed", switching to different HTTPS URI don't help, but it is functioning under HTTP protocol.
I tried to set proxy selector to shadow-socks (a proxy software), it throws the same Exception again.
In fiddler console, it showed fiddler refused that request with statue code 400, message "Fiddler - Bad Request", "[Fiddler] HTTP Request specified an invalid port number."
Request captured by fiddler:
"
CONNECT socket://www.google.com:443/ HTTP/1.1
Content-Length: 0
Host: socket://www.google.com:443/
"
It seems specify default port causes this problem, although there's no specification that specified this, but for compatibility this should be "fix".
The error message should be more than "Tunnel failed" as well
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
launch the fiddler software or some proxy software
construct an HttpClient, version is HTTP_1_1, set ProxySelector to that proxy software
Send a request under HTTPS protocol use that HttpClient
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
200 or some other status code
ACTUAL -
java.io.IOException: Tunnel failed
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.io.IOException: Tunnel failed
at jdk.incubator.httpclient/jdk.incubator.http.PlainTunnelingConnection.connect(PlainTunnelingConnection.java:80)
at jdk.incubator.httpclient/jdk.incubator.http.SSLTunnelConnection.connect(SSLTunnelConnection.java:52)
at jdk.incubator.httpclient/jdk.incubator.http.Http1Exchange.sendHeadersOnly(Http1Exchange.java:136)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl0(Exchange.java:298)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl(Exchange.java:245)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.response(Exchange.java:121)
at jdk.incubator.httpclient/jdk.incubator.http.MultiExchange.response(MultiExchange.java:154)
at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:234)
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
HttpResponse<String> send = HttpClient
.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
// fiddler
.proxy(ProxySelector.of(new InetSocketAddress(InetAddress.getLoopbackAddress(), 8888)))
// shadow-socks
// .proxy(ProxySelector.of(new InetSocketAddress(InetAddress.getLoopbackAddress(), 1080)))
.build()
.send(
HttpRequest
.newBuilder()
.uri(URI.create("https://www.google.com"))
.GET()
.build(),
HttpResponse.BodyHandler.asString()
);
System.out.println(send.statusCode());
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Customize a proxy software that can accept this form of request.