起因是这样的,线上log经常出现Connection Reset异常,从堆栈上分析是solr进行sharding request时发生的,solr部署在tomcat上。从现场来看,原因很明白Server端发出RST包。但具体原因是什么就得经过一番分析了,
FIN
procedure.
public static void run(){ try{ //InetSocketAddress address = new InetSocketAddress("10.58.99.27", 9090); //InetAddress address = InetAddress.getByName("10.58.99.27"); ServerSocket serverSocket = new ServerSocket(9090,1); ExecutorService threadPool = Executors.newCachedThreadPool(); // for(int i = 0; i < 1;i++){ // new Thread(new BioHttpServer.Connector()).start(); // } // latch.countDown(); while(true){ Socket client = serverSocket.accept(); Thread.sleep(1000);//调整这个时间 如调整为100 则为情况1 1000为情况2 client.close(); // client.shutdownOutput(); // if(isDistribute){ // threadPool.execute(new SocketProcessor(client)); // }else{ // new SocketProcessor(client).run(); // } } }catch(Exception e){ e.printStackTrace(); }finally{ } }
try { Socket client = new Socket("10.58.99.74", 9090); // client.setSoTimeout(5000); System.out.println(client); InputStream ins =client.getInputStream(); int i = 0; // System.out.println(ins.read()); while(i++ < 100000){ client.getOutputStream().write(64); } System.out.println(ins.read()); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }