Skip to content
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

redis for default websocket driver error #308

Closed
zhongjq opened this issue Jul 14, 2019 · 8 comments
Closed

redis for default websocket driver error #308

zhongjq opened this issue Jul 14, 2019 · 8 comments

Comments

@zhongjq
Copy link

zhongjq commented Jul 14, 2019

Make sure you read Issues Guideline and answer these questions before submitting your issue. Thanks!
(Any non-English issues will be closed immediately.)

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)
    php 7.3.6
    swoole 4.3.3

  2. Please provide your Laravel/Lumen version.
    laravel 5.7

  3. Which release version of this package are you using?
    v2.6.63

  4. What did you do? If possible, provide a recipe for reproducing the error.

I use the redis for default websocket driver,There are occasional log errors in the production environment.
reference

//swoole_websocket.php
/*
    |--------------------------------------------------------------------------
    | Default websocket driver
    |--------------------------------------------------------------------------
    */
    'default' => 'redis',

log error

Symfony\Component\Debug\Exception\FatalThrowableError: Argument 2 passed to SwooleTW\Http\Websocket\Rooms\RedisRoom::removeValue() must be of the type array, int given, called in /mnt/data/wwwroot/qtopay.net/vendor/swooletw/laravel-swoole/src/Websocket/Rooms/RedisRoom.php on line 121
#3 vendor/swooletw/laravel-swoole/src/Websocket/Rooms/RedisRoom.php(160): removeValue
#2 vendor/swooletw/laravel-swoole/src/Websocket/Rooms/RedisRoom.php(121): delete
#1 vendor/swooletw/laravel-swoole/src/Websocket/Websocket.php(150): leave
#0 vendor/swooletw/laravel-swoole/src/Concerns/InteractsWithWebsocket.php(174): null

  1. What did you expect to see?

  2. What did you see instead?
    i have no idea, mybe i will use table for default websocket driver

@albertcht
Copy link
Member

albertcht commented Jul 28, 2019

Hi @zhongjq ,

I'm not able to reproduce this issue on my local environment. And I find it weird that this shouldn't happen in this function:

public function delete(int $fd, $rooms)
{
    $rooms = is_array($rooms) ? $rooms : [$rooms];
    $rooms = count($rooms) ? $rooms : $this->getRooms($fd);

    $this->removeValue($fd, $rooms, RoomContract::DESCRIPTORS_KEY);
    // ...

The first $rooms variable must be array type. The second $rooms must be array as well because $this->getRooms($fd) calls smembers function from predis, and it must return an array.

Comment below if anyone finds other possible clues.

@zhongjq
Copy link
Author

zhongjq commented Jul 29, 2019

Hi @albertcht
Yes, this is my low probability event in the production environment so I doubt it will happen when high concurrency is online.
I have also studied the code and found no logic problems. This error does not affect the operation of my online website, so it is not easy to locate

@liyu001989
Copy link

liyu001989 commented Aug 1, 2019

same issue with redis driver , low probability. I trid to logger $rooms , the value is 1。

@albertcht
Copy link
Member

@liyu001989 , thanks for your info, I will try to figure it out yet no clues now.

@liyu001989
Copy link

I add some logs in Websocket/Rooms/RedisRoom.php

image

sometimes redis smembers return 1 or 0

image
image

In redis-cli or tinker smembers is ok

image
image

the smembers function not always returning array,any idea ?

@albertcht
Copy link
Member

Hi @liyu001989 , thanks for your report, I will keep digging on it.

@killtw
Copy link
Contributor

killtw commented Aug 19, 2019

It would be found after unsuspected disconnect happen

@albertcht
Copy link
Member

I try to fix that error in the release v2.6.64. Can you try to keep watching on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants