-
Notifications
You must be signed in to change notification settings - Fork 75
Problem when the connection is closed to early for the client to know it #70
Comments
Hello, Did you try to listen the $bucket->getSource()->close(
Websocket\Connection::CLOSE_POLICY_ERROR,
'Invalid user or campaign given.'
); should do the trick and it saves one TCP message over the network. Just curious: How did you implement the |
About the Line 139 in 9b0418d
It allowed me to retrieve HTTP Request details from the incoming connection. At the beginning I've used the second parameter for the "reason" on I already listen to The full error stack trace here : [ErrorException]
stream_socket_shutdown(): supplied resource is not a valid stream resource
Exception trace:
() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/hoa/socket/Connection/Connection.php:337
Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at n/a:n/a
stream_socket_shutdown() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/hoa/socket/Connection/Connection.php:337
Hoa\Socket\Connection\Connection->mute() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/hoa/websocket/Client.php:258
Hoa\Websocket\Client->close() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/hoa/websocket/Connection.php:240
Hoa\Websocket\Connection->_run() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/hoa/socket/Connection/Handler.php:195
Hoa\Socket\Connection\Handler->run() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/hoa/websocket/Client.php:131
Hoa\Websocket\Client->run() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/app/Console/Commands/Socket/Client.php:54
App\Console\Commands\Socket\Client->handle() at n/a:n/a
call_user_func_array() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/laravel/framework/src/Illuminate/Container/Container.php:507
Illuminate\Container\Container->call() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/laravel/framework/src/Illuminate/Console/Command.php:169
Illuminate\Console\Command->execute() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/symfony/console/Command/Command.php:256
Symfony\Component\Console\Command\Command->run() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/laravel/framework/src/Illuminate/Console/Command.php:155
Illuminate\Console\Command->run() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/symfony/console/Application.php:791
Symfony\Component\Console\Application->doRunCommand() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/symfony/console/Application.php:186
Symfony\Component\Console\Application->doRun() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107
Illuminate\Foundation\Console\Kernel->handle() at /Users/shulard/Sites/Clients/MonQuiz.fr/back/artisan:35 After some researchs I found that there are some operations performed on the socket stream inside $connection->mute();
$connection->setStreamTimeout(0, 2 * 15000); // 2 * MLS (on FreeBSD)
$connection->read(1); Each of these calls are throwing an exception because : |
Hmm, so the connection can be disconnected at this particular place too. How do you feel trying a patch? |
I guess this is related to #71. Can you reproduce your issue with this PR? If yes, then it does not fix your issue but this is related and I can update this PR. |
Hello ! I think I can try a patch, I know that library code better now 😄. I'm gonna try to reproduce with the #71 PR and post results here. |
Hello,
I'm currently writing a WebSocket daemon to notify users when some data are updating. I want to retrieve some context from the WebSocket connection so I use the socket url to pass parameters. For example:
ws://127.0.0.1:8889/campaign/1/user/1
To check that URL contains valid informations, I wrote a simple
onOpen
handler on my server. If the check does not pass, I close the connection. The next time the client need to read through the socket, it's already closed and I got the following php error :Server code
Client code
If I gave a valid URL to the client, no problem but if I gave a wrong one, the connection is closed by the server and the client know it only the next time he try to read on it.
I've checked in library code and it seems that the
getStream
method on the socket connection return null (so theErrorException
thrown is just logic here...).Is it the right way to handle that kind of verification ?
The text was updated successfully, but these errors were encountered: