Skip to content

The connection is not automatically removed in WebSocketServer when the client is disconnected #163

@leolee3914

Description

@leolee3914

I am using the WebSocketServer. When the client reconnects, the following situations occur:

[2021-03-03 22:33:09][info] Ip "tcp://192.168.31.1:13345" establish connection
[2021-03-03 22:33:10][info] Ip "tcp://192.168.31.1:13347" establish connection
[2021-03-03 22:33:10][info] Ip "tcp://192.168.31.1:13348" establish connection
[2021-03-03 22:33:11][info] Ip "tcp://192.168.31.1:13350" establish connection
[2021-03-03 22:33:11][info] Ip "tcp://192.168.31.1:13351" establish connection
[2021-03-03 22:33:12][info] Ip "tcp://192.168.31.1:13353" establish connection
[2021-03-03 22:33:15][info] Ip "tcp://192.168.31.1:13357" establish connection
[2021-03-03 22:33:16][info] Ip "tcp://192.168.31.1:13359" establish connection

WebSocketServer::onDisconnect() is not called.

$socketStream->on('end', function () use($connection) {

When I changed to $socketStream->on('close', Closure);, the connection is automatically closed:

[2021-03-03 22:35:12][info] Ip "tcp://192.168.31.1:45664" establish connection
[2021-03-03 22:35:17][info] Ip "tcp://192.168.31.1:45664" left connection
[2021-03-03 22:35:17][info] Ip "tcp://192.168.31.1:45674" establish connection
[2021-03-03 22:35:18][info] Ip "tcp://192.168.31.1:45674" left connection
[2021-03-03 22:35:18][info] Ip "tcp://192.168.31.1:45678" establish connection
[2021-03-03 22:35:18][info] Ip "tcp://192.168.31.1:45678" left connection
[2021-03-03 22:35:18][info] Ip "tcp://192.168.31.1:45680" establish connection
[2021-03-03 22:35:19][info] Ip "tcp://192.168.31.1:45680" left connection
[2021-03-03 22:35:19][info] Ip "tcp://192.168.31.1:45682" establish connection
[2021-03-03 22:35:20][info] Ip "tcp://192.168.31.1:45682" left connection
[2021-03-03 22:35:20][info] Ip "tcp://192.168.31.1:45684" establish connection

Sorry for my bad English

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