-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple new Connection initiates #17
Comments
Agree. I connect with the following code...
And the socket server registers two connections. Is there any workaround for this, @arthurkushman ? |
Hi, could You provide more info on this? How do run client, let's assume that the server is running commonly without any additional configuration, in other words I need 100% client code to reproduce and explore. Thx |
Sure, I'm testing in localhost, so I'm disabling SSL verification. Full code is as follows:
I've also tried send/receive on the aforementioned $client and it works as expected (albeit twice)... the server receives the sent message and returns a response, which the client receives without a problem. It's just that it happens twice. The server is quite standard. With the above code it logs two separate connections. When I connect to the same server with the the following javascript code, the server only receives a single connection (as hoped/expected)
I have also tried connecting to the server with Flutter (a cross-platform mobile framework) and it behaves exactly the same as the javascript example (single connection). I appreciate this is difficult to debug, are the comments from the original bug not helpful? |
I'm running the web-socket server in one tab and client in another with this code: $recvMsg = '{"user_id" : 123}';
$client = new WebSocketClient($this->url, new ClientConfig());
try {
$client->send($recvMsg);
} catch (BadOpcodeException $e) {
echo 'Couldn`t sent: ' . $e->getMessage();
}
$recv = $client->receive();
$this->assertEquals($recv, $recvMsg); Getting this particular result:
Probably there some miscellaneous connections in your case from 2 clients ex. browser and console? |
It's a mystery. The server I'm running is this one, which is based on Ratchet. The 2 connections are definitely a result of the php client connecting (a single time). I'm pretty new to socket programming... I wonder if the way that the php client connects is interpreted by the server as two separate connections? |
It is a mystery for me either, because I have never used laravel web-socker server, but for my own interest I've installed it and run with
It is returning
I don't know why and I don't want to spend my time investigating it to be honest. |
Thanks anyway - I appreciate your efforts. I'll let you know if I ever find out the cause. |
I can see you have more than one
new Connection
For better performance I would recommend only doing it once but then store all connections in an array like you store all clients as a property in the class
The text was updated successfully, but these errors were encountered: