Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
并发测试下javanio的断管错误_Java_Concurrency_Webserver_Nio_Java Io - Fatal编程技术网

并发测试下javanio的断管错误

并发测试下javanio的断管错误,java,concurrency,webserver,nio,java-io,Java,Concurrency,Webserver,Nio,Java Io,我现在正在使用JavaNIO构建一个事件驱动服务器 当我使用ab-n100-c100localhost:8080/时,一切都很好。 但是当我执行ab-n1000-c1000 localhost:8080/时,出现了错误 守则的一部分: resHeader.append("Host: MyServer" + CRLF); resHeader.append("Connection: close" + CRLF + CRLF); ByteBuffer temp = ByteBuffer.wrap(re

我现在正在使用JavaNIO构建一个事件驱动服务器

当我使用ab-n100-c100localhost:8080/时,一切都很好。 但是当我执行ab-n1000-c1000 localhost:8080/时,出现了错误

守则的一部分:

resHeader.append("Host: MyServer" + CRLF);
resHeader.append("Connection: close" + CRLF + CRLF);
ByteBuffer temp = ByteBuffer.wrap(resHeader.toString().getBytes());--(ClientHandler.java:372)
while(temp.hasRemaining()) {
    client.write(temp);
}
ByteBuffer temp = null;
try {
    temp = ByteBuffer.wrap(resHeader.toString().getBytes());
    while(temp.hasRemaining()) {
        client.write(temp);
    }
} catch (IOException e) {
    System.err.println("TEST: " + temp.hasRemaining());
    System.out.println("connect:" + client.isConnected()
    // TODO Auto-generated catch block
    e.printStackTrace();
}
客户端的定义:client=SocketChannel key.channel

错误发生后,我将以下内容添加到代码中:

resHeader.append("Host: MyServer" + CRLF);
resHeader.append("Connection: close" + CRLF + CRLF);
ByteBuffer temp = ByteBuffer.wrap(resHeader.toString().getBytes());--(ClientHandler.java:372)
while(temp.hasRemaining()) {
    client.write(temp);
}
ByteBuffer temp = null;
try {
    temp = ByteBuffer.wrap(resHeader.toString().getBytes());
    while(temp.hasRemaining()) {
        client.write(temp);
    }
} catch (IOException e) {
    System.err.println("TEST: " + temp.hasRemaining());
    System.out.println("connect:" + client.isConnected()
    // TODO Auto-generated catch block
    e.printStackTrace();
}
当错误再次弹出时,它会打印TEST:true和connect:true,这意味着它没有完成编写。为什么会这样

此外,我还使用了ab-C1000-N10000-rhttp://localhost:8080/

PS:使用这个-r,我没有得到错误:java.io.IOException:breaked pipe


这是否提供了一些有用的信息

“断管”表示对等方过早地关闭了连接。它可以在负载下完成这项工作,原因有很多,而这些都与您的代码无关。

您的操作系统每个进程可以打开的套接字的最大数量是多少?另外,ab是否会过早关闭插座?