View Single Post
  #1 (permalink)  
Old 12-04-2007, 05:04 PM
Waccoon Waccoon is offline
Member
 
Join Date: Dec 2007
Location: MA, USA
Posts: 2
Waccoon is on a distinguished road
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:

Quote:
access denied (java.net.SocketPermission <IP ADDRESS>:80 connet, resolve)
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?

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.

Code:
URL url = new URL(getCodeBase(), p("url_save", "picture.cgi")); int k = url.getPort(); socket = new Socket(url.getHost(), k <= 0 ? 80 : k);
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.

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.
Reply With Quote
Sponsored Links