server up and client receives java.net.ConnectException: Connection refused

Hi,

I have a typical client/server application and I am having some problems. At the beginning I always can connect from the client to the server. However if I restart the server and the client only sometimes can connect and some others I receive the following:

java.net.ConnectException: Connection refused

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)

at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)

at java.net.Socket.connect(Socket.java:452)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(DashoA6275)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(DashoA6275)

at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(DashoA6275)

I am using java 1.4.2. I think it has something to do with leaving the socket port opened when I finish the program but I don't see anything with netstat -a | grep port_number and also I have a socketInstance.close() in a finalize method in my program.

Any idea?

Thanks in advance,

[1188 byte] By [dolmedilla.dea] at [2007-9-29 19:32:10]
# 1

My experience has been that:

Exception: java.net.ConnectException: Connection refused

means that the IP address active but SSL is not listening on that port.

Essentially, the reciever is not listening for SSL on that port.

You can point a browser (IE) to the url/port and see if it can connect.

-Steve

69speed69a at 2007-7-15 20:48:16 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2

Right. The port is not listening. The problem is why it is not listening if it didn't give me any exception before and the port was free when I tried to open it? I have a code that works and open the socket and listen for connections. The connections are made and work perfectly. If now I stop the execution, the socket is now free and the port is not listening. The problem is when I start again the execution and I try to open again the port with the same code that worked before. This time I don't receive any exception but when I check if it is listening for connections in that port, the answer is not, it is not listening. Any idea about why?

dolmedilla.dea at 2007-7-15 20:48:16 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 3
Hi,I have the similar problem. I am getting "java.net.connectException" error inconsistently. Did you find any solution to fix this issue?Regards,arc
arckeanea at 2007-7-15 20:48:16 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...