Home > front end >  Socket communication, server after a period of time can't receive the data
Socket communication, server after a period of time can't receive the data

Time:10-04

 public class InOutDataService implements InitializingBean and Runnable {
The @autowired
SysIOMapper SysIOMapper;
Private Logger Logger=Logger. GetLogger (enclosing getClass ());

Private static final int PORT=10101;
Private static ServerSocket ServerSocket.
Private static Boolean isStartServer=false;
Private static Socket client;
Private static BufferedReader reader;

@ Override
Public void afterPropertiesSet () throws the Exception {
New Thread (this). The start ();
}

@ Override
Public void the run () {
While (true) {
System. The out. Println (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- start now -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "+ DateUtils. GetDateStr (DateUtils. DATETIMESHOWFORMAT));
Try {
ServerSocket=new serverSocket (PORT);
The client=serverSocket. The accept ();
} the catch (IOException e) {
e.printStackTrace();
}
IsStartServer=true;
While (isStartServer) {
Try {
List List=null;
Reader=new BufferedReader (new InputStreamReader (client. GetInputStream ()));
String MSG=reader. ReadLine ();
If (MSG!=null) {
System. The out. Println (MSG);
String msg1;
//this code to handle the message
}
//Thread. Sleep (10000);
} the catch (Exception e) {
Logger. Error (um participant etMessage ());
Try {
Reader. The close ();
Client. The close ();
ServerSocket. Close ();
IsStartServer=false;
Thread.sleep (1000);
{} the catch (IOException | InterruptedException e1)
Logger. Error (um participant etMessage ());
E1. PrintStackTrace ();
}
Logger. Error (um participant etMessage ());
e.printStackTrace();
}
}
}
}
}

CodePudding user response:

Is that service program is receiving data, and then about 1 days are normal, suddenly a mental note time is less than the data, if there is something wrong with the code, the great god, please grant instruction

CodePudding user response:

Never make, shaking hands is interrupted, you can connect again

CodePudding user response:

Give you a possible, for reference,
There is a network firewall, Anti - DDOS, WAF safety protective equipment, such as if it have any restrictions on the long link, may be forced off the end of the

CodePudding user response:

refer to the second floor u012804915 response:
never get, shaking hands is interrupted, you can connect again

I just restart the program and data immediately

CodePudding user response:

reference ambit_tsai reply: 3/f
give you a possible, for reference,
There is a network firewall, Anti - DDOS, WAF safety protective equipment, such as if it have any restrictions on the long link, may be forced off the end of the

Client is 10 seconds to send a to me, this limitation is timeout limit

CodePudding user response:

reference 5 floor a65568641 reply:
Quote: refer to the third floor ambit_tsai response:

Give you a possible, for reference,
There is a network firewall, Anti - DDOS, WAF safety protective equipment, such as if it have any restrictions on the long link, may be forced off the end of the

Client is 10 seconds to send a to me, this limitation is a timeout limit

Link building is too long, more than allow the length of the safety equipment, may be forced to interrupt,

CodePudding user response:

Hello I met this problem the client is now suddenly don't get the message but connection showed normal, currently has found the reason and solution?

CodePudding user response:

reference 13 floor liuyangtest12138 reply:
hello I met this problem the client is now suddenly don't get the message but connection showed normal, currently has found the reason and solution?


Excuse me solve? What reason be cause of I also encountered the same problem now thank you!!!!!!

CodePudding user response:

Hello I met this problem the client is now suddenly don't get the message but connection showed normal, currently has found the reason and solution?

CodePudding user response:

The building Lord problem solved, today also encountered a similar situation
  • Related