Skip to content

Client Ping/Pong broken in 1.6 #170

Open

Description

@MarcusOhman91

Pong request payload does not match ping response payload (which causes the websocket server I try to interact with to close the connection)

In my scenario the ping from the websocket server is an empty string. When producing the pong response, the pushFrame is invoked receiving the following $frame argument: [true,"","pong",false]. This in turn produces a $data of �\u0000" which is written to the stream.

I could quickfix it for my scenario by changing this line
$this->write($data);
to
$this->write($opcode === 'pong' ? '' : $data);

But I instead solved it by downgrading to v1.5.8 where the ping/pong interaction seems to work fine.

Reproduced with PHP 8.1.12 (cli)
version 1.6.3

Activity

  1. sirn-se commented on Nov 8, 2022

    @sirn-se
    Contributor

    Did some checks, and the autoresponder do reply as expected on empty message. The issue you have is probably related to masking. This has been wrong all along, but it appears my attempt to improve things in v1.6 caused other issues instead. I'll have a look at that when I've got some time for it.

    As a side note, the quick fix you mention means the client do not send a pong when receiving ping at all. The $data variable is the entire frame, not only the payload.

  2. sirn-se commented on Nov 12, 2022

    @sirn-se
    Contributor

    Hi @MarcusOhman91

    I did a rewrite of masking policy that (hopefully) will solve the issue you're experiencing; #171

    However, the servers I'm testing with work with v1.6 as is. So I would appreciate if you're able to confirm that this fix solves things for you before I merge it to master. You should be able to test by specifying dev-1.6-fixes in Composer.

    Thanks in advance!

  3. sirn-se commented on Nov 22, 2022

    @sirn-se
    Contributor

    @MarcusOhman91
    Please switch to phrity/websocket (official fork of this repo), version 1.6.4 should solve your issue.

  4. thorewi commented on Jan 1, 2023

    @thorewi

    The PR was closed and not merged, why?

  5. MarcusOhman91 commented on May 11, 2023

    @MarcusOhman91
    Author

    @MarcusOhman91 Please switch to phrity/websocket (official fork of this repo), version 1.6.4 should solve your issue.

    delayed response, but can confirm that this worked.

    I guess this issue should be left open if any of the remaining maintainers decides to fix it in this repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions