Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Unable to establish a socket connection

Reply
Thread Tools

Unable to establish a socket connection

 
 
S J Rulison
Guest
Posts: n/a
 
      10-20-2004
Can somebody please give me a clue as to what I'm doing wrong here? I
have a JAVA Applet and Server application written in JAVA version
1.4.2_05 running on a Windows XP platform. I use the socket(String
host, int port) class on the applet side to establish a connection
with the Server and the ServerSocket(int port) class on the server
side. When I run both the Server and Applet on the same workstation,
everything works fine but if I move the Server portion onto another
machine, I am unable to establish a connection with that Server. I've
tried using the IP address of the server, the name of the client, and
the fully qualified name (client.domain_name). All of these methods
worked fine when I ran them on the same machine. For whatever its
worth, I tried feeding the server a fetishes IP Address and machine ID
when I was running both programs from the same machine to see if it
would run anyway and it did not. So the server program is doing
something with that parameter.

So, is it a rights issue that I'm dealing with or is it something
else? Any help would be greatly appreciated.

Thank you.
 
Reply With Quote
 
 
 
 
Ann
Guest
Posts: n/a
 
      10-20-2004

"S J Rulison" <> wrote in message
news: om...
> Can somebody please give me a clue as to what I'm doing wrong here? I
> have a JAVA Applet and Server application written in JAVA version
> 1.4.2_05 running on a Windows XP platform. I use the socket(String
> host, int port) class on the applet side to establish a connection
> with the Server and the ServerSocket(int port) class on the server
> side. When I run both the Server and Applet on the same workstation,
> everything works fine but if I move the Server portion onto another
> machine, I am unable to establish a connection with that Server. I've
> tried using the IP address of the server, the name of the client, and
> the fully qualified name (client.domain_name). All of these methods
> worked fine when I ran them on the same machine. For whatever its
> worth, I tried feeding the server a fetishes IP Address and machine ID
> when I was running both programs from the same machine to see if it
> would run anyway and it did not. So the server program is doing
> something with that parameter.


What is a 'fetishes IP address'

>
> So, is it a rights issue that I'm dealing with or is it something
> else? Any help would be greatly appreciated.
>
> Thank you.



 
Reply With Quote
 
 
 
 
S J Rulison
Guest
Posts: n/a
 
      10-21-2004
"Ann" <> wrote in message news:<0rBdd.429785$Fg5.208530@attbi_s53>...
> "S J Rulison" <> wrote in message
> news: om...
> > Can somebody please give me a clue as to what I'm doing wrong here? I
> > have a JAVA Applet and Server application written in JAVA version
> > 1.4.2_05 running on a Windows XP platform. I use the socket(String
> > host, int port) class on the applet side to establish a connection
> > with the Server and the ServerSocket(int port) class on the server
> > side. When I run both the Server and Applet on the same workstation,
> > everything works fine but if I move the Server portion onto another
> > machine, I am unable to establish a connection with that Server. I've
> > tried using the IP address of the server, the name of the client, and
> > the fully qualified name (client.domain_name). All of these methods
> > worked fine when I ran them on the same machine. For whatever its
> > worth, I tried feeding the server a fetishes IP Address and machine ID
> > when I was running both programs from the same machine to see if it
> > would run anyway and it did not. So the server program is doing
> > something with that parameter.

>
> What is a 'fetishes IP address'
>
> >
> > So, is it a rights issue that I'm dealing with or is it something
> > else? Any help would be greatly appreciated.
> >
> > Thank you.


How about Factitious? Does that make a little more since?
 
Reply With Quote
 
Thomas Schodt
Guest
Posts: n/a
 
      10-21-2004
S J Rulison wrote:
>
> I use the socket(String
> host, int port) class on the applet side to establish a connection
> with the Server and the ServerSocket(int port) class on the server
> side. When I run both the Server and Applet on the same workstation,
> everything works fine but if I move the Server portion onto another
> machine, I am unable to establish a connection with that Server.


With the default security settings, I believe
an Applet can only establish a socket connection to
the domain the applet was fetched from.
 
Reply With Quote
 
Filip Larsen
Guest
Posts: n/a
 
      10-21-2004
S J Rulison wrote

> Can somebody please give me a clue as to what I'm doing wrong here? I
> have a JAVA Applet and Server application written in JAVA version
> 1.4.2_05 running on a Windows XP platform. I use the socket(String
> host, int port) class on the applet side to establish a connection
> with the Server and the ServerSocket(int port) class on the server
> side. When I run both the Server and Applet on the same workstation,
> everything works fine but if I move the Server portion onto another
> machine, I am unable to establish a connection with that Server.


You do not write what exception you get, but a guess would be that your
experience the security manager denying your applet to connect to any
other host than the host from where the applet came. If that is the
case, try use Applet.getCodeBase() in the applet to check that the host
really is the one you think. In fact, you can use the code base URL
directly to ensure you always connect to the originating host by using
getCodeBase().getHost() as the hostname when you create your sockets.


Regards,
--
Filip Larsen


 
Reply With Quote
 
S J Rulison
Guest
Posts: n/a
 
      10-21-2004
Thomas Schodt <> wrote in message news:<cl7jii$4nm$1$>...
> S J Rulison wrote:
> >
> > I use the socket(String
> > host, int port) class on the applet side to establish a connection
> > with the Server and the ServerSocket(int port) class on the server
> > side. When I run both the Server and Applet on the same workstation,
> > everything works fine but if I move the Server portion onto another
> > machine, I am unable to establish a connection with that Server.

>
> With the default security settings, I believe
> an Applet can only establish a socket connection to
> the domain the applet was fetched from.


Well, I'm not sure exactly what you mean but I can tell you that both
the server and the client reside on the same domain. The domain
controller for our netwrok is a Windows 2000 Adv. server.
 
Reply With Quote
 
S J Rulison
Guest
Posts: n/a
 
      10-22-2004
"Filip Larsen" <> wrote in message news:<cl87ma$adu$>...
> S J Rulison wrote
>
> > Can somebody please give me a clue as to what I'm doing wrong here? I
> > have a JAVA Applet and Server application written in JAVA version
> > 1.4.2_05 running on a Windows XP platform. I use the socket(String
> > host, int port) class on the applet side to establish a connection
> > with the Server and the ServerSocket(int port) class on the server
> > side. When I run both the Server and Applet on the same workstation,
> > everything works fine but if I move the Server portion onto another
> > machine, I am unable to establish a connection with that Server.

>
> You do not write what exception you get, but a guess would be that your
> experience the security manager denying your applet to connect to any
> other host than the host from where the applet came. If that is the
> case, try use Applet.getCodeBase() in the applet to check that the host
> really is the one you think. In fact, you can use the code base URL
> directly to ensure you always connect to the originating host by using
> getCodeBase().getHost() as the hostname when you create your sockets.
>
>
> Regards,


Actually, I didn't get any exceptions. And I guess I should have
mentioned that in my original post. Thnak you for the headsup on the
getCodeBase() & getHost() methods. I will look into that and see if
that fixes the problem.

Thanks again.


Sincerely,
Steve Rulison.
 
Reply With Quote
 
Steve Horsley
Guest
Posts: n/a
 
      10-22-2004
S J Rulison wrote:
>
> Actually, I didn't get any exceptions. And I guess I should have
> mentioned that in my original post.


In that case you are connecting succesfully. There are only two
possible outcomes to calling new Socket(), and that is either
a connected socket, or an exception thrown.

Maybe you are catching and ignoring the exception?

Steve
 
Reply With Quote
 
S J Rulison
Guest
Posts: n/a
 
      10-26-2004
Steve Horsley <> wrote in message news:<clbvbo$89f$>...
> S J Rulison wrote:
> >
> > Actually, I didn't get any exceptions. And I guess I should have
> > mentioned that in my original post.

>
> In that case you are connecting succesfully. There are only two
> possible outcomes to calling new Socket(), and that is either
> a connected socket, or an exception thrown.
>
> Maybe you are catching and ignoring the exception?
>
> Steve


Dear Mr. Horsley:
You were correct in your reply to my post when you stated that I might
be catching and ignoring the exception. Upon further review of my
code, I noticed that I had the e.printstackTrace(System.err) commented
out. I have printed out the exceptions that were thrown below. It
appears that I need to go threw the java security manager and grant
permission to the applet to open a socket connection to the server
application but I'm not exactly sure how that's done. Do you know of
any examples I can look at to see what code needs to be added to the
applet and the application? The closest I came to finding an example
was a snippet of code for granting permissions:
grant{java.security.AllPermissions;}. I wasn't able to figure out
where this fits into the scheme of things.


I would really appreciate any help you could give me on this.

Thanks.


EXCEPTIONS:
java.security.AccessControlException: access denied
(java.net.SocketPermission 10.44.250 resolve)
at java.security.AccessControlContext.checkPermission (Unknown Source)
at java.security.AccessController.checkPermission(Unk nown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at java.net.InetSocketAddress.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at PTABLookup.createSocket(PTABLookup.java:110)
at PTABLookup.init(PTABLookup.java:87)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
 
Reply With Quote
 
Steve Horsley
Guest
Posts: n/a
 
      10-26-2004
S J Rulison wrote:
> Steve Horsley <> wrote in message news:<clbvbo$89f$>...
>
>>S J Rulison wrote:
>>
>>>Actually, I didn't get any exceptions. And I guess I should have
>>>mentioned that in my original post.

>>
>>In that case you are connecting succesfully. There are only two
>>possible outcomes to calling new Socket(), and that is either
>>a connected socket, or an exception thrown.
>>
>>Maybe you are catching and ignoring the exception?
>>
>>Steve

>
>
> Dear Mr. Horsley:
> You were correct in your reply to my post when you stated that I might
> be catching and ignoring the exception. Upon further review of my
> code, I noticed that I had the e.printstackTrace(System.err) commented
> out. I have printed out the exceptions that were thrown below. It
> appears that I need to go threw the java security manager and grant
> permission to the applet to open a socket connection to the server
> application but I'm not exactly sure how that's done. Do you know of
> any examples I can look at to see what code needs to be added to the
> applet and the application? The closest I came to finding an example
> was a snippet of code for granting permissions:
> grant{java.security.AllPermissions;}. I wasn't able to figure out
> where this fits into the scheme of things.
>
>
> I would really appreciate any help you could give me on this.
>
> Thanks.
>
>
> EXCEPTIONS:
> java.security.AccessControlException: access denied
> (java.net.SocketPermission 10.44.250 resolve)
> at java.security.AccessControlContext.checkPermission (Unknown Source)
> at java.security.AccessController.checkPermission(Unk nown Source)
> at java.lang.SecurityManager.checkPermission(Unknown Source)
> at java.lang.SecurityManager.checkConnect(Unknown Source)
> at java.net.InetAddress.getAllByName0(Unknown Source)
> at java.net.InetAddress.getAllByName0(Unknown Source)
> at java.net.InetAddress.getAllByName(Unknown Source)
> at java.net.InetAddress.getByName(Unknown Source)
> at java.net.InetSocketAddress.<init>(Unknown Source)
> at java.net.Socket.<init>(Unknown Source)
> at PTABLookup.createSocket(PTABLookup.java:110)
> at PTABLookup.init(PTABLookup.java:87)
> at sun.applet.AppletPanel.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)


Now you've caught me out. I've never messed around with security managers,
so I can't help you. But now you know what the problem is, maybe someone else
can chip in. Or maybe you can google for something like "applet socket
securityexception". This has been discussed many times before.

Steve
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to establish secure connection with the server Harry ASP .Net Security 2 10-22-2007 09:06 AM
Unable to establish secure connection with the server Toze ASP .Net Security 0 06-14-2007 05:40 PM
Unable to establish secure connection with the server Jerry C ASP .Net Security 8 06-16-2006 05:51 AM
Unable to establish home network =?Utf-8?B?Qm9iIGluIERF?= Wireless Networking 3 11-15-2004 12:44 AM
Unable to re-establish GPRS connection after failed Web Service David ASP .Net Mobile 0 10-22-2004 08:55 AM



Advertisments