[xSocket-develop] xsocket ssl through proxy problem
Status: Inactive
Brought to you by:
grro
|
From: Poladian, G. <gra...@ci...> - 2008-06-25 20:57:24
|
First, very nice job with this library. Its very well organized and
works well.
Currently, using xsocket 2.1 and http 2.0 beta 1.
When connecting to https server through a proxy the following
combination does not work.
--------------------------------------------
HttpRequest connect_http = new
HttpRequest("CONNECT","somecompany.com:443");
...
NonBlockingConnection proxy_conn = new
NonBlockingConnection("proxy.net",8080,ssl_context,false);
HttpClientConnection http_conn = new HttpClientConnection (proxy_conn);
IHttpResponse connect_response = proxy_conn.call(connect_http);
Thread.sleep(2000);
System.out.println("Activating Secure Mode ...");
http_conn.activateSecureMode();
Getting the following exception:
Activating Secure Mode ...
java.nio.channels.ClosedChannelException
at
org.xsocket.connection.AbstractNonBlockingStream.readByteBufferByLength(
AbstractNonBlockingStream.java:546)
at
org.xsocket.connection.NonBlockingConnection.readByteBufferByLength(NonB
lockingConnection.java:1259)
at
org.xsocket.connection.NonBlockingConnection.activateSecuredMode(NonBloc
kingConnection.java:1212)
at
org.xsocket.connection.http.AbstractHttpConnection.activateSecuredMode(A
bstractHttpConnection.java:429)
--------------------------------------------
However, the following works fine
--------------------------------------------
static String CONNECT_STRING = "CONNECT somecompany.com:443
HTTP/1.1\r\n"
+"Connection: keep-alive\r\n"
+"Proxy-Connection: keep-alive\r\n"
+"Pragma: no-cache\r\n"
+"Keep-Alive: 300\r\n"
+"Host: somecompany.com:443\r\n"
+"\r\n";
NonBlockingConnection proxy_conn = new
NonBlockingConnection("proxy.net",8080,ssl_context,false);
proxy_conn.write(CONNECT_STRING);
proxy_conn.flush();
while(not_finished_reading) {
proxy_conn.read(...)
}
proxy_conn.activateSecuredMode();
--------------------------------------------
After stepping through the code a bit it seems that the channel is being
closed after the CONNECT
request is processed. So the subsequent handshake fails. You need to be
stepping in the dispather and main
threads to see this.
Regards,
Grant
|