olegk wrote:
>
> On Mon, 2010-07-05 at 19:16 -0700, Jacky-Zhu-1 wrote:
>>
>>
>> olegk wrote:
>> >
>> > On Mon, 2010-07-05 at 08:56 -0700, Jacky-Zhu-1 wrote:
>> >>
>> >>
>> >> olegk wrote:
>> >> >
>> >> > On Sun, 2010-07-04 at 11:39 -0700, Jacky-Zhu-1 wrote:
>> >> >> I've been trying to use httpclient4.0 to connect https server via
>> >> socks
>> >> >> proxy, but it failed again and again.
>> >> >>
>> >> >
>> >> > SOCKS is a TCP/IP level, not HTTP level protocol. SOCKS proxy
>> support
>> >> > can be configured using standard JVM settings.
>> >> >
>> >> > Oleg
>> >> >
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: [email protected]
>> >> > For additional commands, e-mail: [email protected]
>> >> >
>> >> >
>> >> >
>> >>
>> >> Hi Oleg, thanks for your reply.
>> >> You are right, SOCKS proxy support could be configured using standard
>> JVM
>> >> settings. But JVM settings is global, it will take effect for all the
>> >> java
>> >> socket, this is not what we want, we just want to use SOCKS proxy for
>> >> part
>> >> of the java sockets, so we want to go through the SOCKS by using
>> >> HttpClient.
>> >> Yes, SOCKS is TCP/IP level, HttpClient focus on HTTP level. But
>> >> HttpClient
>> >> supports to create customized socket by implementing the
>> >> SocketFactory/LayeredSocketFactory, am I right?
>> >> And JVM supports layered SSLSocket, I've checked the JVM code and the
>> >> JSSE
>> >> code, JVM could support to let user pass one connected socket to one
>> >> SSLSocket.
>> >>
>> >> So the solution I have tried is something like this:
>> >> 1. create one normal socket, and connect it to the proxy server
>> >> 2. complete the socks protocol using this socket
>> >> 3. passed this socket to a new created SSLSocket
>> >> 4. let HttpClient use this new SSLSocket to communicate with HTTPS
>> server
>> >>
>> >> I've checked the running status, the steps 1/2/3 are all ok, but the
>> step
>> >> 4
>> >> failed, as the log I have pasted.
>> >>
>> >> Could you give me some advices?
>> >> Or maybe I can read the HttpClient source code to get some clues.
>> >>
>> >
>> > Have a look at this example. Please note it requires HttpClient 4.1
>> > (still ALPHA)
>> >
>> >
>> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java
>> >
>> > Oleg
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [email protected]
>> > For additional commands, e-mail: [email protected]
>> >
>> >
>> >
>>
>> Hi Oleg,
>>
>> Thanks for your reply.
>> It seems that your example is only suitable for normal socket, not
>> suitable
>> for sslsocket. I also found in
>> http://old.nabble.com/Fw:-SOCKS-proxy-example---td28306808.html#a28306808
>> another thread , you have given an similar example for HttpClient4.0, I
>> have
>> tried that solution, it did work for normal socket in HttpClient4.0, but
>> didn't work for sslsocket.
>> So I think this example still cannot work for sslsocket, because for JVM
>> sslsocket, the only solution to using sslsocket via socks proxy is that:
>> create normal socket and connect it to the proxy server; complete the
>> socks
>> protocol using this socket's input/output stream;create one sslsocket
>> using
>> this socket.
>>
>> My problem is how to let HttpClient4.0 use this customized sslsocket.....
>>
>
> That is exactly what socket factories are for
>
> http://hc.apache.org/httpcomponents-client-4.0.1/tutorial/html/connmgmt.html#d4e484
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
Hi Oleg,
Yes, I have implemented my SocksSSLSocketFactory who has implemented the
SocketFatory interface, as the code I pasted.
In the debug mode, I also found this class was used by HttpClient, and the
function createSocket and connectSocket of the SocksSSLSocketFactory were
calle, everything is ok before return from connectSocket: the normal socket
has been created and conneted to proxy server, the socks4 protocol finished
successfully, the sslsocket is created using this normal socket
successfully, but after return this sslsocket from connectSocket, the error
happens, from the log I found that this sslsocket was shutdown, I don't know
why, I don't know what happend after connectSocket returned the sslsocket.
So my problem is that the sslsocket I created was shutdown after I returned
it to HttpClient in connectSocket function.
10-07-05 10:57:42,269 DEBUG -Get connection for route
HttpRoute[{}->https://10.64.69.13:9000]
[org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:195)]
2010-07-05 10:57:42,269 DEBUG -Get connection for route
HttpRoute[{}->https://10.64.69.13:9000]
[org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:195)]
2010-07-05 10:57:42,286 DEBUG -Connection shut down
[org.apache.http.impl.conn.DefaultClientConnection.shutdown(DefaultClientConnection.java:141)]
2010-07-05 10:57:42,286 DEBUG -Connection shut down
[org.apache.http.impl.conn.DefaultClientConnection.shutdown(DefaultClientConnection.java:141)]
2010-07-05 10:57:42,287 DEBUG -Releasing connection
org.apache.http.impl.conn.singleclientconnmanager$connadap...@19ab6f6
[org.apache.http.impl.conn.SingleClientConnManager.releaseConnection(SingleClientConnManager.java:250)]
2010-07-05 10:57:42,287 DEBUG -Releasing connection
org.apache.http.impl.conn.singleclientconnmanager$connadap...@19ab6f6
[org.apache.http.impl.conn.SingleClientConnManager.releaseConnection(SingleClientConnManager.java:250)]
2010-07-05 10:57:42,287 ERROR
-executeRequest=============================:class:class
java.net.SocketException:Socket is not connected
[com.trendmicro.imss.ui.modelobjects.prefilter.client.CommonUtils.executeRequest(CommonUtils.java:641)]
--
View this message in context:
http://old.nabble.com/How-to-use-httpclient4.0-to-connect-HTTPS-via-socks-proxy--tp29070494p29091968.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]