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

Undefined offset: 2 #2

Closed
smallpen opened this issue Apr 27, 2018 · 6 comments
Closed

Undefined offset: 2 #2

smallpen opened this issue Apr 27, 2018 · 6 comments

Comments

@smallpen
Copy link

smallpen commented Apr 27, 2018

Sometime use websocket to receive prices will happen exception "Receive server happen exception => Undefined offset: 2" ! Here is my code

try {
            $this->webSocket_client->onUpdate(function ($symbol, $data) {
                echo "[" . Carbon::now('Asia/Taipei')->toDateTimeString() . "] Receive {$symbol} ..." . PHP_EOL;
                echo "[" . Carbon::now('Asia/Taipei')->toDateTimeString() . "] Price => " . var_dump($data) . PHP_EOL;
                try {
                    $price = round($data['price'], 6);
                    $id = $this->product_list[$symbol];
                    $this->product_redisServer->hset($id, 'price', $price);
                } catch (\Exception $exception) {
                    echo "[" . Carbon::now('Asia/Taipei')->toDateTimeString() . "] Receive price happen exception => {$exception->getMessage()}" . PHP_EOL;
                }
            });

            $this->webSocket_client->onMessage(function ($message) {
                echo $message;
            });

            $this->webSocket_client->connect(function ($client) {
                //Subscribe to an array of currency pairs
                $client->subscribeTo([
                    'EURUSD',
                    'USDJPY',
                    'AUDUSD',
                    'GBPUSD',
                    'EURGBP',
                    'EURJPY',
                    'GBPJPY',
                    'BTCUSD',
                    'ETHUSD',
                    'XAUUSD',
                    'XAGUSD'
                ]);
            });
        } catch (\Exception $exception) {
            echo "[" . Carbon::now('Asia/Taipei')->toDateTimeString() . "] Receive server happen exception => {$exception->getMessage()}" . PHP_EOL;
        }
@brutus-gr
Copy link

Hello,

Can you please tell me what version of the library you are currently using (in your composer.json file).

@smallpen
Copy link
Author

name : oneforge/forexquotes
descrip. : Library to fetch and parse realtime Forex quotes and convert currencies
keywords : api, forex, quotes, realtime
versions : * 2.0.10
type : library

@smallpen
Copy link
Author

Here is trace log !

BinaryGameServer: Receive 1forge price happen exception!Task has been stop! Error=> Undefined offset: 2, Trace => #0 /home/chris/GameServer/vendor/wisembly/elephant.io/src/Engine/AbstractSocketIO.php(125): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined offse...', '/home/chris/Gam...', 125, Array) #1 /home/chris/GameServer/vendor/wisembly/elephant.io/src/Client.php(86): ElephantIO\Engine\AbstractSocketIO->read() #2 /home/chris/GameServer/vendor/oneforge/forexquotes/lib/ForexDataClient.php(162): ElephantIO\Client->read() #3 /home/chris/GameServer/app/Console/Commands/receivePrice.php(118): OneForge\ForexQuotes\ForexDataClient->connect(Object(Closure)) #4 [internal function]: App\Console\Commands\receivePrice->handle() #5 /home/chris/GameServer/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array) #6 /home/chris/GameServer/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #7 /home/chris/GameServer/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) #8 /home/chris/GameServer/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) #9 /home/chris/GameServer/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array) #10 /home/chris/GameServer/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #11 /home/chris/GameServer/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #12 /home/chris/GameServer/vendor/symfony/console/Application.php(946): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #13 /home/chris/GameServer/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\receivePrice), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #14 /home/chris/GameServer/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #15 /home/chris/GameServer/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #16 /home/chris/GameServer/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #17 /home/chris/GameServer/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #18 {main}

@brutus-gr
Copy link

brutus-gr commented Apr 30, 2018

Hi @smallpen,

I am having trouble replicating the issue.

Can you tell me:

  1. How often does this happen. Every time you run it, or seemingly randomly?
  2. Do you notice anything else when it happens (eg: dropped connection, market closing, etc...)

@smallpen
Copy link
Author

smallpen commented May 3, 2018

It seem this issue ! Wisembly/elephant.io#149

@brutus-gr
Copy link

brutus-gr commented May 6, 2018

@smallpen It looks like the library isn't maintained anymore unfortunately. You might be better of switching to javascript and using https://www.npmjs.com/package/forex-quotes - it's far more stable.

We'll eventually try to move off of elephant.io or switch to a fork that's more stable.

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

No branches or pull requests

3 participants