Return-Path: Delivered-To: apmail-jakarta-httpclient-user-archive@www.apache.org Received: (qmail 48595 invoked from network); 4 Apr 2007 19:52:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Apr 2007 19:52:43 -0000 Received: (qmail 32524 invoked by uid 500); 4 Apr 2007 19:52:49 -0000 Delivered-To: apmail-jakarta-httpclient-user-archive@jakarta.apache.org Received: (qmail 32514 invoked by uid 500); 4 Apr 2007 19:52:49 -0000 Mailing-List: contact httpclient-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: "HttpClient User Discussion" Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-user@jakarta.apache.org Received: (qmail 32503 invoked by uid 99); 4 Apr 2007 19:52:49 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 12:52:49 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of johnbrayton@gmail.com designates 64.233.166.182 as permitted sender) Received: from [64.233.166.182] (HELO py-out-1112.google.com) (64.233.166.182) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 12:52:40 -0700 Received: by py-out-1112.google.com with SMTP id f31so104911pyh for ; Wed, 04 Apr 2007 12:52:19 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=gQL6R9SmOMSR0EmyPvsfW4Vx1Dh3qDM1oyCicdSRtq0vkMnGdnf8RdXYn2sBlmyJ0ynnEe2PPNFsfwwQ+pmCPDF7EJ7mVNI8Vsdu+G9KG3O2Vi16uRkrb6jheigUWRYReX9D/ZY2HJ0OPDJtlHxl0MSAPRWHW8zHkQyNvVqNUcU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=UqfqeHL3xgKvyUEMZoteeVTCUzhT7OmGwa0acgnSfUSGFVDrRCLVmd+YxtdSwZUwU+d1BrvqSFFI15rsZs/Mpj3uEeqZFFkvoj3pu51dSSOnFKPpdZTBouI9Y2krxRHrN20fX2ZVZw81vu3QpKOwrrLfQVYIpNBCLAscLrwtvYA= Received: by 10.35.41.12 with SMTP id t12mr1707503pyj.1175716339683; Wed, 04 Apr 2007 12:52:19 -0700 (PDT) Received: by 10.35.84.8 with HTTP; Wed, 4 Apr 2007 12:52:19 -0700 (PDT) Message-ID: Date: Wed, 4 Apr 2007 15:52:19 -0400 From: "John Brayton" To: httpclient-user@jakarta.apache.org Subject: HttpClient/Socket within Applet behind SOCKS v4 proxy In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Checked: Checked by ClamAV on apache.org I am wondering if someone can shed some light on a problem I am having using HTTPClient in an applet running behind a SOCKS v4 proxy. Client System Configuration: -IE6 on Win XP -Java 1.5.0_11 -Applet is using HTTP Client 3.0.1. If IE is configured to connect directly to the web server, or is configured to use a SOCKS v5 proxy, the applet works as expected. If IE is configured to connect to a SOCKS v4 proxy, I get this exception: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SOCKSSocketImpl.readSOCKSReply(Unknown Source) at java.net.SOCKSSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80) at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122) at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) This happens regardless of whether I set the "socksProxyHost" and "socksProxyPort" system properties. Note that in my test environment, the applet could connect directly to the web server if it tried to, so it seems that the applet is trying to connect to via the SOCKS v4 proxy. Based on the debug information above, the error is occuring on this constructor within DefaultProtocolSocketFactory: new Socket(host, port, localAddress, localPort); The "host" and "port" parameter values are correct; localAddress is set to null, and localPort is set to 0. So the constructor call looks correct. If I call this Socket constructor at the start of the applet with hard-coded values I get identical symptoms: Socket(String,int) Packet-sniffing with Ethereal shows that while IE is making SOCKS v4 connections and succeeding; the applet is trying to make SOCKS v5 connections and failing. Perusing the JVM code, the "java.net.SocksSocketImpl" class has a setV4() method, but I can't find anything in the JVM that ever calls it. The logical thing to do would be to call that setV4() method, but the method is not public; a class has to be within the "java.net" namespace in order to call it. And trying to create my own "java.net" class results in a SecurityException, even from within a PrivilegedAction.run() method. I don't believe an applet can have an "endorsed" class. What I suspect would theoretically work is this: -Copying the JVM "java.net.SocksSocketImpl" class into my own class namespace, in addition to the non-public code within the "java.net" namespace that it needs. -Calling SocksSocketImpl.setV4(). -Calling Socket.setSocketImplFactory(...) with a factory that returned my own SocksSocketImpl object. But I'd have to copy a *lot* of "java.net" JVM code, creating a big mess and perhaps violating the JVM source license, so this seems like a bad idea. Does anyone have any advice on this? John --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-user-help@jakarta.apache.org