java - Simple open socket hanging very infrequently -
I have a code that is hanging in Java. The hanging happens very often, probably because of the order of 1000 hanging it does not reproduce the problem of running it in a loop in any device.
Long time expired = 10000; Long end time = System.currentTimeMillis () + timeout + 5000; Socket ping sign = faucet; String host = "host"; String port = "22"; Do {try} {pingSocket = new socket ()); PingSocket.bind (zero); PingSocket.connect (new InetSocketAddress (host, port), 5000); If (pingSocket.isConnected ()) {pingSocket.close (); Back true; } PingSocket.close (); } Hold (unknown haphazard e) {throw e; } Hold (IOException E) {// All other errors are subclassed with IOException, and I want to ignore // my spin duration until then. } {Thread Try sleep (SPIN_SLEEP_DELAY); } Grip (Interrupted e) E. {return false; }} While (system syentime milliseconds) & lt; = endtime);
Since this happens occasionally in production, it has become difficult to reduce the problem. I am currently in the process of writing code so that this information is in the next release of our product, when it is, but I thought that someone asks that someone has just tied up / connected / connected / stopped? / P>
Thanks!
Did you create a Java thread dump during hanging? It will tell you that your code is hanging.
Comments
Post a Comment