Home > Back-end >  Socket connection, one of the user exit after cause the failure of other user communication, ask for
Socket connection, one of the user exit after cause the failure of other user communication, ask for

Time:09-26

about process goes like this:
Web front end user login -- "the background & lt; <- a thread continued heartbeat packets sending and receiving data keep long socket TCP connection - & gt;> The service side
Web front end user exit -- "the background & lt; <-- -- -- -- -- disconnected, end thread -- -- -- -- -- & gt;> The service side

:
I use a user testing, no problem, the login is successful, the receiver data success, exit is also OK,
But when two users such as A, B all login keep communication, if A user exit, cause the failure of B user communication, see error message socket is close,

excuse me:
Please help to analysis what causes such a situation, thank you,

:
User exit background processing process:

Send out data to the server, and then the end thread, joined a whether to withdraw from the identity of the ( issysout )
Public class TxThread extends Thread {
While (true) {
If (issysout) {
System. The out. Println (" user exit from the heartbeat, exit the threads ");
return;
}
}

Is excuse me this out of the problems identified? According to my understanding, a logged in user a single thread, the end of the thread should not affect other users,

CodePudding user response:

Looks a little like, a connection is closed, all connections, or the server is closed,
You check, do you have a Shared server connection closed action, is triggered,

CodePudding user response:

Your server is how to create a socket? Is don't share the same socket?
Is your issysout thread own property? A Shared variable or the server?

CodePudding user response:

refer to the second floor qybao response:
your server side is how to create a socket? Is don't share the same socket?
Is your issysout thread own property? A Shared variable or the server?


Issysout is a variable,
The socket=new socket (host, port);//rest calls this socket
The service side is somebody else's program, can't modify,
Now test found
Such as A log on first (192.168.10.111, 1088)
After the user login, B (192.168.10.111, 1089)
Then A user exit, the result is found that the user is out of the B,
. Then I print System. Under the out println (" sending socket address: "+ socket);
Socket [addr=/192.168.10.111, port=1088, localport=54893] Socket information is user B,

That is called is the last login user socket,
  • Related