Client ConnectException "Connection refused"

If a client try to connect to a server which is currently down, it happens a ConnectException “Connection refused” which is normally caught by the abstract class Connection in this block:

[java]

public abstract class Connection implements Runnable {



public void run() {

try {



} catch (ConnectException ce) {

log.log(Level.WARNING, “[{0}][???] Connection refused.”, label);

}

}



}[/java]

I would to handle this exception in other way: writing this onto a panel created by nifty instead of into the logger.

Must I to split the IOException block into two catch blocks, one for the ConnectException, in which I just throw to handle in my way, and the other one for the rest of the IOExceptions, which I leave into the log?

Or is there a easier manner to know if a client connection has been refused?

Thanks

r.

I’ll have a look if there’s a way to provide users with the ability to detect network errors. Mostly it’s a problem with threading - you can throw exceptions in threads, but they will not end up with the user, where they sometimes should end up. A semi-logical solution to this is having an extra listener, but I’ll check if there’s a good way to do this.

I just checked, and the ConnectException catch block calls fireClientDisconnected(null), in other words you can tell from the disconnection event. Would it be better to have a separate listener for connection errors? What do you (and other monkeys) think?

Hhmmzz…



You could use the disconnect event, but somehow this doesn’t feel right to me. The main reason being that a failed connect has nothing to do with a disconnect. I would rather have expected it to be a special kind of connect event, seeing how you can listen vor those as well.

As it is an event related to a connect action, calling fireClientConnected would seem more appropriate.



I’m not sure we would need a whole new listener for this one tbh. Using the connect event listener you have availlable already should be more then enough. You could then just wait for a call to that method to determine if the connect was successfull or not, and take it from there.

Hi, I’ve been a few weeks away from jme. Any good news about handling this misconnection?