Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Proxy settings causing unwanted use of SOCKS

843790Dec 19 2007 — edited Jul 19 2013
I have a Java app that, among other things, has to connect to a web server and get a response. Pretty simple stuff. I needed to be able to support proxy servers out of the box. So I looked around and discovered the ProxySelector and the java.net.useSystemProxies=true property. I read that it would auto-magically detect proxy settings for the platform. I added the code to detect and use the proxy if present and it worked without a hitch in testing.

I was contacted by a customer stating that they weren't able to communicate to the internet. I looked at my logs and saw that I was detecting their HTTP proxy server and port correctly. I spoke to their proxy server administrator and confirmed everything. Then, I saw this in the logs:
java.net.SocketException: Malformed reply from SOCKS server
	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.<init>(Unknown Source)
	at java.net.Socket.<init>(Unknown Source)
They were not using a SOCKS proxy, only a standard HTTP proxy. The customer's IE could connect to the site without issue. I then asked them to describe their IE connection settings to me. They said they simply checked "Use a proxy server for your LAN" and entered the proxy address and port. I asked them to check the "Advanced" proxy settings and they had "Use the same proxy server for all protocols" checked, and that's it. They mentioned that they had never clicked "Advanced" when setting it up.

I setup my machine's config to match theirs and I got the issue to occur. I then un-checked "Use the same proxy server for all protocols" and everything worked fine. No SOCKS sockets were used.

Hopefully you're still with me here...

Why does Java assume that it should use SOCKS for the socket and IE does not when "Use the same proxy server for all protocols" is checked? How can I prevent this from happening?

Specs: WinXP, Java 6, IE 7

Edited: Changed title...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 16 2013
Added on Dec 19 2007
3 comments
10,650 views