Skip to content

纯协程版http服务器支持http2协议吗? #5858

@ewei-dev

Description

@ewei-dev

Swoole\Coroutine\Http\Server
文档中提到:若编译时开启 HTTP2,则默认会启用 HTTP2 协议支持,无需像 Swoole\Http\Server 一样配置 open_http2_protocol (注:v4.4.16 以下版本 HTTP2 支持存在已知 BUG, 请升级后使用)。
php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team team@swoole.com
Version => 5.1.4
Built => Nov 15 2024 12:55:33
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 3.0.2 15 Mar 2022
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
zlib => 1.2.11
brotli => E16777225/D16777225
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

SSL配置支持了https,但是http2测试失败(No ALPN negotiated):

No client certificate CA names sent
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: X25519, 253 bits

SSL handshake has read 1663 bytes and written 377 bytes
Verification: OK

New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)


Post-Handshake New Session Ticket arrived:
SSL-Session:
Protocol : TLSv1.3
Cipher : TLS_AES_256_GCM_SHA384
Session-ID: C4915174A35F73A8479F71442489EB6A59D8E7C4EF632A3123E71789113282BA
Session-ID-ctx:
Resumption PSK: 854CCE3945A8A23608B972D25E624E095CD4CD15AE982ADFABB8FFCA1AC995556DEA4BD0E45498C0BC3AA92CAAEDE715
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 7200 (seconds)
TLS session ticket:
0000 - 96 87 00 88 86 44 ae c2-1c ce 7d 73 92 2a ad 50 .....D....}s.*.P
0010 - 78 60 64 fd d7 84 d9 7c-24 70 df 98 82 79 18 e8 xd....|$p...y.. 0020 - e4 16 8e 92 fe 89 45 bb-3c 3f ba de ac 0b 1c 5c ......E.<?.....\ 0030 - 7b 46 ef 37 92 71 cb 0e-01 a8 d6 d6 7e e6 23 fc {F.7.q......~.#. 0040 - ab 78 e6 b8 69 f2 44 f7-f1 53 c7 7b 34 02 e0 6a .x..i.D..S.{4..j 0050 - 8f f7 ab 84 48 10 35 c9-88 1f f5 b6 d4 35 4c 91 ....H.5......5L. 0060 - 25 bc 22 81 53 a6 41 31-e4 f5 f5 4c 12 49 c7 02 %.".S.A1...L.I.. 0070 - ae 13 10 3a 66 b7 52 a1-43 b5 11 bf 4c 4a 7a 2b ...:f.R.C...LJz+ 0080 - 70 09 29 f5 13 ea 9f 6e-4c 20 90 48 45 e9 a8 14 p.)....nL .HE... 0090 - a3 a7 35 42 64 4f b6 f2-a0 d9 f4 ec 6d 1f 28 4d ..5BdO......m.(M 00a0 - 70 fa 4f e4 08 ef 8d db-b3 5a b0 1e 2f 70 cf a9 p.O......Z../p.. 00b0 - 60 ef a2 71 51 d6 68 f3-86 0b 12 0a 30 20 49 0e ..qQ.h.....0 I.
00c0 - be a5 a5 eb 58 11 23 f0-94 78 d4 30 a8 2f 3a f1 ....X.#..x.0./:.

Start Time: 1758264737
Timeout   : 7200 (sec)
Verify return code: 0 (ok)
Extended master secret: no
Max Early Data: 0

read R BLOCK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions