Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-25.2.0 | composer require openswoole/core:22.1.5
It is possible to compress data frames when pushing WebSocket data to the client, the client must support compression in order to receive such a request. If you enable WebSocket data compression, you can use the OpenSwoole\WebSocket\Server::WEBSOCKET_FLAG_COMPRESS
flag to compress a specific data frame.
The example below is a good guide on how WebSocket compression works but you must also enable it via the websocket_compression
configuration option before the server starts up.
Once enabled the server will give time specifically to check if compression is supported in accordance with WebSocket RFC-7692.
You can enable WebSocket Frame Compression and use it on a specific data frame.
OpenSwoole Server
OpenSwoole Client
See the push()
method documentation on where to specifically use the OpenSwoole\WebSocket\Server::WEBSOCKET_FLAG_COMPRESS
flag, it is part of the int $flags
parameter.