Operating System - HP-UX
1819874 Members
2716 Online
109607 Solutions
New Discussion юеВ

Java socket connection exception

 
Chamitha Wijesekera
Frequent Advisor

Java socket connection exception

Hi, my application creates an agent at a specified port and then requests a url from that port.

url = new URL( "http://eshpa004:8082/vgnstatus/xmltree");
urlConn = (HttpURLConnection)url.openConnection();
is = urlConn.getInputStream();

where,
url = URL object
urlConn = HttpURLConnection object
is = InputStream object
eshpa004 = machine name (HP-UX)

The following exception is thrown by the getInputStream method.

java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at sun.net.NetworkClient.doConnect(NetworkClient.java:50)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:331)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:517)
at sun.net.www.http.HttpClient.(HttpClient.java:267)
at sun.net.www.http.HttpClient.(HttpClient.java:277)
at sun.net.www.http.HttpClient.New(HttpClient.java:289)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:411)
at utests.java.classes.unit.monitor.framework.AgentTest.send(AgentTest.java:401)

I can load the url in a web browser perfectly. Hence the agent is connected and online. Any suggestions?

3 REPLIES 3
Steven Sim Kok Leong
Honored Contributor

Re: Java socket connection exception

Hi,

If your normal connections from your web browser (e.g. IE) is through a HTTP proxy server, then your perl script's direct connection to port 80 will not work. This is because a direct connect does not go through the HTTP proxy server and is thus blocked.

Hope this helps. Regards.

Steven Sim Kok Leong
Chamitha Wijesekera
Frequent Advisor

Re: Java socket connection exception

I'm not using a proxy server. I even checked its use in the code, so that cant be the problem.
Chamitha Wijesekera
Frequent Advisor

Re: Java socket connection exception

The exact same code works fine on a Windows 2000 platform. So it sure seems like an HP-UX OS issue.