0

我已经实现了一个带有Swoole 服务器集成的Mezzio 框架,与 Swoole 一起服务,以及一个PHP中的 grpc-client 。Swoole 通过Http/2 协议的一元调用获取 grpc-request并驱动 onRequest 事件。然后关联的侦听器获取事件并将 Swoole-request 转换为 PSR7Request。之后,Mezzio 使用相关的处理程序或中间件处理请求以生成PSR7Response

最后,Swoole 发出状态码、标头、cookie,并从 PSR7Response 发出正文。

结果,我看到 Swoole 对 grpc-request(通过 Http/2)的响应是 Http/1.1 响应(不是 application-grpc 响应类型)。

有什么方法可以让 Swoole-Mezzio 集成返回一个带有 application-grpc over Http/2 协议类型的响应

Swoole 配置文件:(autoload -> swoole.local.php )

'mezzio-swoole' => [

    'hot-code-reload' => [
        // Time in milliseconds between checks to changes in files.
        'interval' => 500,
        'paths'    => [
            // List of paths, either files or directories, to scan for changes.
            // By default this is empty; you will need to configure it.
            // A common value:
            getcwd(),
            '/',
            '/var/www/MezzioSwoole/'
        ],
    ],

    // Configure Swoole HTTP Server:
    'swoole-http-server' => [
        'host' => '192.168.10.190',
        'port' => 8003,
        'mode' => SWOOLE_BASE, // SWOOLE_BASE or SWOOLE_PROCESS;
        // SWOOLE_BASE is the default
        'protocol' => SWOOLE_SOCK_TCP, // | SWOOLE_SSL, // SSL-enable the server
        'options' => [
            // Set the SSL certificate and key paths for SSL support:
            //  'ssl_cert_file' => __DIR__ . '/../../data/swoole/ssl.crt',
            //  'ssl_key_file' => __DIR__ . '/../../data/swoole/ssl.key',

            // Whether or not the HTTP server should use coroutines;
            // enabled by default, and generally should not be disabled:
            'enable_coroutine' => true,

            // Overwrite the default location of the pid file;
            // required when you want to run multiple instances of your service in different ports:
            // 'pid_file' => 'path/to/pid_file.pid',

            // Enable HTTP2 protocol
            'open_http2_protocol' => true,

            'listeners' => [
                // Register the hot code reloader listener with the WorkerStartEvent
                WorkerStartEvent::class => [
                    \Mezzio\Swoole\Event\HotCodeReloaderWorkerStartListener::class,
                ],
            ],
        ],
    ],
],
4

0 回答 0