Socket refused, but applet talking to native server
Hi, everyone. I've got a real hair-puller on my hands.
I've been having an odd problem with an old applet and socket connections with Java v6. I've read that applets do not need to be signed to connect to servers from which the applet was downloaded. However, since Java v6 was released, some servers have been throwing this permission error:
This doesn't make sense. If the applet is downloaded from "www.mysite.com" and the applet is trying to open a socket on "www.mysite.com", this shouldn't result in a permission error, should it?
access denied (java.net.SocketPermission <IP ADDRESS>:80 connet, resolve)
What really confuses me is that this only happens on some servers but not others, which would suggest a server problem, but only Java v6 is causing the applet to complain, so it has to be a client problem (or both). I can't seem to find any real pattern as to which servers will have the issue and which will not. It doesn't seem to make a difference whether the web host is free or commercial.
The code fails on the call for a new socket, so it has nothing to do with writing to the socket. The applet also supports "url.openConnection()" as an alternative, but this also fails with the same SocketPermission error when trying to connect.
URL url = new URL(getCodeBase(), p("url_save", "picture.cgi"));
int k = url.getPort();
socket = new Socket(url.getHost(), k <= 0 ? 80 : k);
The applet is designed to be redistributable, so I do not have a "codebase" defined in my HTML.
I have access to a server that returns the error, so I can test code changes. Is it possible that getCodeBase() can fail in some cases? Does anyone know what might have changed in Java v6 that would suddenly cause this issue to show up, while Java v5 works fine? Is there some special security initialization that needs to happen before a socket is opened? I didn't see anything in the socket tutorials I've been researching.
I know little about Java, but my PHP script is dependent on this applet, so I need to figure out what's wrong. The applet author lives in Japan and I've had no luck contacting him for the last year, so I can't get help that way.
Possible bug in Java 1.6.0
Well, it appears I've found my answer.
A problem has been discovered in the Firefox version of Java 1.6.0_03
If you know anyone who is having issues with a Java applet using 1.6.0_r3, please let them know about this.
Although only some servers are affected by this issue, I can confirm that all the affected servers I've tested WILL work with Internet Explorer and Opera using the same version of Java. Apparently, only Firefox is affected.
I will also test Safari and Firefox on my old Mac to see if the OSX version of Java has this issue as well.
I guess this will teach me to use different browsers when testing for Java applet compatibility, and not just HTML layout.