Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http协程服务close 异常,存在 CLOSE_WAIT #5176

Closed
Dmcz opened this issue Nov 1, 2023 · 3 comments
Closed

Http协程服务close 异常,存在 CLOSE_WAIT #5176

Dmcz opened this issue Nov 1, 2023 · 3 comments

Comments

@Dmcz
Copy link

Dmcz commented Nov 1, 2023

请求结束后服务端未正确关闭, 还是我的使用方式有些问题?

简单实现一个HTTP协程服务

<?php
declare(strict_types=1);

use Swoole\Coroutine\Http\Server;
use function Swoole\Coroutine\run;

run(function () {
    try {
        $server = new Server('127.0.0.1', 9501, false);
        $server->handle('/', function ($request, $response)   {
            try {
                $response->end('finished');
            } catch (\Throwable $th) {
                var_dump($th->getMessage());
            }
        });

        $server->start();

    } catch (\Throwable $th) {
        var_dump($th->getMessage());
    }
});

通过curl请求

curl -w "\n" http://127.0.0.1:9501/
finished

查看连接

netstat -ano | grep 9501
tcp        0      0 127.0.0.1:9501          0.0.0.0:*               LISTEN      off (0.00/0/0)
tcp        0      0 127.0.0.1:9501          127.0.0.1:40186         CLOSE_WAIT  off (0.00/0/0)
tcp        0      0 127.0.0.1:9501          127.0.0.1:54560         CLOSE_WAIT  off (0.00/0/0)

swoole 版本信息

php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 5.1.0
Built => Oct 29 2023 14:12:40
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 3.0.2 15 Mar 2022
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
c-ares => 1.18.1
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
@NathanFreeman
Copy link
Member

可以试试master分支,我在master分支没有发现这个问题

@NathanFreeman
Copy link
Member

Fixed by #5163

@Dmcz
Copy link
Author

Dmcz commented Nov 5, 2023

master分支没问题, 谢谢啦

@Dmcz Dmcz closed this as completed Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants