Skip to content

feature: support permessage connection in websocket #157

@sc0Vu

Description

@sc0Vu

Hi there,

Thanks for this great library. Recently, I’ve been trying to connect to the server with permessage-deflate. While the connection was established, the message wasn’t compressed, which led to a frame error. I tried encoding the message myself, but it didn’t work because the frame wasn’t correct. I noticed there is a deflateFrame method in MessageBuffer, and I believe it can support permessage-deflate in WebSocket.

In my opinion, the permessage-deflate can be added when initializing the stream (https://github.com/ratchetphp/Pawl/blob/master/src/WebSocket.php#L69).

Let me know if you have any suggestions.

        $permessageDeflateOptions = PermessageDeflateOptions::fromRequestOrResponse($request);
        $sender = null;
        $permessageDeflateOption = null;
        if (count($permessageDeflateOptions) > 1) {
            $sender = [$stream, 'write'];
            $permessageDeflateOption = $permessageDeflateOptions[0];
        }
        $streamer = new MessageBuffer(
            ......
            null,
            null
            $sender,
            $permessageDeflateOption
        );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions