Strange hanging socket?

I have a client server application with a java server. It works very well, except that after a long period of time, the nest suddenly hangs. This socket is one of many, the rest seems to be all right, but as soon as it gets into the socket, the server just does not go past the sending line. These are the relevant code snippets:

Socket socket; // A normal socket
out  = new PrintWriter(socket.getOutputStream(), true); // The outstream
out.println(msg + "\0"); // This command is used to send stuff, msg is a String

No exceptions are thrown, the line application simply does not pass the line:

out.println(msg + "\0");

I know that String is good, calling 4 or 5 other sockets before this one can send it just fine. Also note that, as far as I know, this socket can send hundreds of messages just fine before it suddenly hangs itself. Does anyone know what error I should look for?

+5
source share
2 answers

There are many things that can lead to this, but it looks like you are probably getting pressure at the TCP level.

Usually, when you send data to a socket, it is simply buffered, and the send call (in your case, println()and flush()) can return before the data is actually sent to the network. Maybe all of your previous entries in this socket were only buffered by local SO_SNDBUF , and you just populated it.

(1) tcpdump Wireshark , ( , )? TCP , , , Java .

(2) . Java- . , , ?

$ jstack <PID>

, , , .

+5

Socket OutputStream , send() : . , , , , , , , , , , .

+3

All Articles