Server/Client stuck in endless loop

when I terminate server (or client) or interrupt tcp connection somehow (unplugging ethernet cable) other side is unable to cope with this and gets stuck in endless loop. There is an IOException poping out in TCPConnection that probably causes this. It would be nice to handle it appropriately, not just log it.



Error message is in Czech, saying that current connection was terminated by remote host



SEVERE: [Server#1][???] Error while selecting. Message: Stávající připojení bylo vynuceně ukončeno vzdáleným hostitelem
3.11.2010 13:58:38 com.jme3.network.connection.Connection run


and stack trace of this exception:

java.io.IOException: Stávající připojení bylo vynuceně ukončeno vzdáleným hostitelem
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
at sun.nio.ch.IOUtil.read(IOUtil.java:200)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
at com.jme3.network.connection.TCPConnection.read(TCPConnection.java:138)
at com.jme3.network.connection.Connection.run(Connection.java:124)
at com.jme3.network.connection.ConnectionRunnable.run(ConnectionRunnable.java:77)
at java.lang.Thread.run(Thread.java:619)


code to reproduce it:

Server
[java]
public class Jme3test {
public static void main(String[] args) throws IOException {
Server s = new Server(32233, 32233);
s.start();
}

}
[/java]

Client
[java]
public class Jme3testcli {

public static void main(String[] args) throws IOException {
Client c = new Client("localhost", 32233, 32233);
c.start();
}

}
[/java]

Compile it, run it, then kill one of sides with task manager

I get the same problems. I have reported this to the creator. Spidermonkey still has a long way to go before it can be used in games. Hopefully we can provide good enough feedback so it gets fixed :slight_smile:

I’m sorry guys, I still haven’t been able to reproduce this. For some reason, forcibly closing my test server/client (on my Mac) results in a clean exit on both ends. (I’ve tried different ways of killing them, even the kill command, etc.) I’ve committed a fix but I’m not sure if it works, going to have to rely on you guys :slight_smile: Let me know if any problems (still) occur.

In windows XP forcing client I have this:

ADVERTENCIA: [Server#1][TCP] Connection was closed before we could read. Disconnected client.



And forcing Server I have this:

18-nov-2010 17:19:56 com.jme3.network.connection.TCPConnection read

ADVERTENCIA: [Client#1][TCP] Server forcibly closed connection. Disconnected.

18-nov-2010 17:19:56 com.jme3.network.connection.TCPConnection read

ADVERTENCIA: [Client#1][TCP] Server closed connection. Disconnected.



So I think it is solved :slight_smile: