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

PHP gRPC Client 调用 Swoole PHP Server 出现 Status Code 为 2 #5

Open
eddycjy opened this issue Dec 7, 2018 · 3 comments
Open

Comments

@eddycjy
Copy link

eddycjy commented Dec 7, 2018

PHP 版本

$ php -v
PHP 7.2.11 (cli) (built: Oct 21 2018 18:28:44) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.11, Copyright (c) 1999-2018, by Zend Technologies

Swoole 版本

$ php --ri swoole

swoole

swoole support => enabled
Version => 4.2.3
Author => Swoole Group[email: team@swoole.com]
coroutine => enabled
kqueue => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.0.2p  14 Aug 2018
http2 => 1.34.0
pcre => enabled
zlib => enabled
brotli => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

背景

1、Server 端:基于 Swoole 的 swoole_http_server 搭建的 gRPC Server
2、Client 端:原生 gRPC 官方提供的 PHP Client

场景

在调用 PHP Client 请求 PHP Server 时,在初次请求中。第一个调用是正常 status code,但是第二个调用就返回 status code 为 2。但是接下来多次请求均正常反馈(不重启 server 的情况下,重启的话又会出现)

返回

第一个调用

stdClass Object
(
    [metadata] => Array
        (
        )

    [code] => 0
    [details] => 
)

$reply 和 $status 均为正常值

第二个调用

stdClass Object
(
    [metadata] => Array
        (
            [server] => Array
                (
                    [0] => swoole-http-server
                )

            [content-encoding] => Array
                (
                    [0] => gzip
                )

        )

    [code] => 2
    [details] => 
)

$reply 为正常值,$status->code 为 2,存在问题!

问题

我的 2个 Client 调用,两个分别单独调用都是正常的。但是一旦都打开,就会出现问题。并且出现问题的那个响应结果 metadata,一定会出现:

 [server] => Array
(
    [0] => swoole-http-server
)
...

只有在初次调用下,存在多个 Client 请求,才会出现这个问题!

第二次一模一样的代码调用就又正常了。考虑到表现上出现了 swoole 的标识符。怀疑是否 swoole 内部做了什么初始化动作,导致 gRPC Status Code 出现异常。但接下来又正常了....

@twose
Copy link
Member

twose commented Dec 27, 2018

可以在非SSL下抓包看看什么情况

@eddycjy
Copy link
Author

eddycjy commented Dec 29, 2018

@twose 抓了包后具体查看哪方面的信息呢?因为数据的确是收到了,而出问题的时候会多出 swoole-http-server ,因此我才怀疑是否 Swoole 做了什么事情?

@zhangweidev
Copy link

zhangweidev commented Aug 20, 2019

我也碰到这个返回错误
不过我使用 php 的 server 没问题,使用 go 的 server 。php client 会出错,返回值

int(2)
string(17) "Http status Error"

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

3 participants