Java. SQL. sqlexception: Io exception: Software caused connection abort: Socket write error
Today, I wrote a broadcast program. There was no problem when I tested it in Java, but the following error was reported during the test with the flash client. After a long time, I couldn't find the cause of the problem. It turns out that Flash software does not automatically create a new thread every time it starts a new client connection like a Java client during testing. Flash closes the connection of the client that was last started every time a new client is restarted. That is to say, the last socket is closed. In this way, when the Java server sends a message to the client, the connection to the client has been closed, so it is naturally unable to receive the message, resulting in a "connection abort" error in Java, in this case, you cannot perform write operations. The cause of this exception is that the client is shut down abnormally or the user is disconnected due to network problems. Therefore, the Java Server should detect the connection status of the client in real time, no matter what causes the user to be disconnected, the user must be deleted from the user's online list. Otherwise, the server will not work properly. In severe cases, the server may die due to blocking, this should be noted.
The best way to solve this problem is to check the connection status of the online user from time to time. Once a connection problem is found, the user is immediately forced to publish the online user list, or delete it from the user queue to be broadcast. In this way, you can ensure that the server does not encounter exceptions during server broadcast due to abnormal user exit.
The following is the exception details:
Java. SQL. sqlexception: Io exception: Software caused connection abort: Socket write error:
Java.net. socketexception: Software caused connection abort: Socket write error At java.net. socketoutputstream. socketwrite0 (NATIVE METHOD) At java.net. socketoutputstream. socketwrite (unknown source) At java.net. socketoutputstream. Write (unknown source) At com. toplx. Game. server. sendmessage. sendobject (Sendmessage. Java: 40) At com. toplx. Game. server. broadcastmsg. sendmsgtoall (Broadcastmsg. Java: 42) At com. toplx. Game. server. gamethread. Run (Gamethread. Java: 53) At java. Lang. thread. Run (unknown source) |