Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.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
Linux TcpListener卡在accept()中,即使客户端认为连接已经建立_Linux_Rust - Fatal编程技术网

Linux TcpListener卡在accept()中,即使客户端认为连接已经建立

Linux TcpListener卡在accept()中,即使客户端认为连接已经建立,linux,rust,Linux,Rust,我花了两天时间解决这个奇怪的问题。rust中的进程可以在我本地的macos、linux、linux上的docker上运行得很好,但不能在aws linux或aws上的k8s上运行。我发现的主要问题是:进程挂起了accept(),甚至客户机都认为它与服务器建立了连接并开始向服务器发送消息ps显示服务器进程处于S状态。代码是用alpha libs编写的,我认为依赖项中可能有一个bug,然后我更新了代码,并用最新版本的依赖项将其切换到稳定的rust,但问题仍然存在。您是否尝试过不执行任何操作来处理连接

我花了两天时间解决这个奇怪的问题。rust中的进程可以在我本地的macos、linux、linux上的docker上运行得很好,但不能在aws linux或aws上的k8s上运行。我发现的主要问题是:进程挂起了
accept()
,甚至客户机都认为它与服务器建立了连接并开始向服务器发送消息
ps
显示服务器进程处于
S
状态。代码是用alpha libs编写的,我认为依赖项中可能有一个bug,然后我更新了代码,并用最新版本的依赖项将其切换到稳定的rust,但问题仍然存在。

您是否尝试过不执行任何操作来处理连接?我们不知道
Nightfort::process
的详细信息,它在
aws linux
上的运行时间可能比预期的长。最后,这可能会导致tokio executor中出现死锁,请参见:@ÖmerErden执行看起来仅达到“debug1”,在aws上运行时,我从未看到调试2、3、4或套接字错误消息。但是在我本地的电脑上看起来不错
let addr: SocketAddr = self.listen_bind.parse().unwrap();
let mut listener = TcpListener::bind(&addr).await?;
info!("Nightfort listening on {}", addr);
loop {
    info!("debug1");
    match listener.accept().await {
        Ok((stream, addr)) => {
            info!("debug2");
            let watcher = self.watcher.clone();
            info!("debug3");
            tokio::spawn(async move {
                info!("debug4");
                if let Err(e) = Nightfort::process(watcher, stream, addr).await {
                    error!("Error on this ranger: {}, error: {:?}", addr, e);
                }
            });
        }
        Err(e) => error!("Socket conn error {}", e),
    }
    // let (stream, addr) = listener.accept().await?;
}