closing connection manually does not trigger onClose
What I've figured out so far
- The connection is reported to be closed for client with the same 1010 code, so it actually gets closed and no problem on that side.
- If the connection is closed by the client, this function gets triggered without any problems.
The problem
I'm doing something like:
$conn->close(1010);
But this function is not triggered.
public function onClose( ConnectionInterface $conn ) {
$this->print("ssss");
parent::onClose( $conn );
}
I use that function to cleanUp connection specific data, so it's kind of important. however I can just call it myself, but I need to know is this a bug or is it intended? (to prevent duplication.)
Also using :
$ws_server->enableKeepAlive($server->loop, 15);
Not sure if that is supposed to help in this case, but it has no effect on this case.
I am Facing Same Problem.did you Find any Solution? @Stevemoretz
I am Facing Same Problem.did you Find any Solution? @Stevemoretz
The workaround is to extend the class, override the close method and call onClose in there.
Can you Please share the Code.
actually I am using enablekeepAlive and it is not Suitable for Large number of websocket Connection
Regarding keep alive that is not necessary nor relevant keep it off.
But You're right my explaining was insufficient, actually it has one more step, you need to create a client wrapper, also you need to put your ratchet server instance in a container or global variable, once you call the close on your client wrapper you need to access the global variable and call onClose in there manually. (of course use your client wrapper in the subclass that extends the main ratchet class)
I can't share my code because it has a lot of dependency subclasses it would be harder to Understand, but that's the way it works under the hood, if you have any further questions feel free to ask.