amphp / websocket-client

Async WebSocket client for PHP based on Amp.
https://amphp.org/websocket-client
MIT License
148 stars 18 forks source link

Ping-Pong Error - Connection Close #26

Closed berkayaksoy closed 3 years ago

berkayaksoy commented 4 years ago

Hello, I am using the stable version published. I coded it from the samples page. There is one server and one client. Both were coded with AMPHP. However, after receiving the server and client responses below, the connection ends.

I can't see the PING-PONG answers. I read that you handle it automatically. However, the situation does not seem that way.

Client Response: Connection closed abnormally while awaiting message; Code 1008 (POLICY_VIOLATION); Reason: "Exceeded unanswered PING limit

Server Response: server.notice: Client initiated websocket close reporting error (code: 1008): Exceeded unanswered PING limit [] []

trowski commented 4 years ago

I'm not able to reproduce any issue with pings. Works as expected.

Could you provide some more details or the script(s) you are using.

makaronnik commented 4 years ago

@yunusberkayaksoy Perhaps your problem can be solved by changing the $queuedPingLimit parameter, by passing the Option object when creating the Handshake:

$options = Options::createClientDefault()->withQueuedPingLimit(10); $handshake = new Handshake('ws://localhost:1337/broadcast', $options); $connection = yield connect($handshake );

Leshkens commented 3 years ago

@yunusberkayaksoy Try with the option withoutHeartbeat():

Options::createClientDefault()->withoutHeartbeat();