php-binance-api icon indicating copy to clipboard operation
php-binance-api copied to clipboard

Socket thread on run

Open sc00scoc opened this issue 6 years ago • 6 comments

Hi, I have a problem when I try to start the web socket on a thread. public function run() { $this->api->trades(["BNBBTC"], function($api, $symbol, $trades) { echo "{$symbol} trades update" . PHP_EOL; print_r($trades); }); }

sc00scoc avatar Feb 22 '19 18:02 sc00scoc

Thank you for your report. I have had multiple issues using RatchetPHP and hopefully someone smart can shine some light on the issue. (and add auto reconnect!)

jaggedsoft avatar Feb 22 '19 18:02 jaggedsoft

There is no way to perform the socket on a thread other than the main thread?

sc00scoc avatar Feb 22 '19 18:02 sc00scoc

Yeah this uses pawl, are you sure you have the right library?

jaggedsoft avatar Feb 22 '19 19:02 jaggedsoft

I'm sure

sc00scoc avatar Feb 22 '19 19:02 sc00scoc

This is error only on run of thread: Uncaught Error: Class 'React\EventLoop\Factory' not found in C:\3 Stack trace:

sc00scoc avatar Feb 22 '19 19:02 sc00scoc

Please confirm your setup. When you are using threads if i recall correctly you must proceed reference to other classes by first referring the global namespace with \ followed by the path to the class namespace.

I'm out for pints ill take a look at my multi threaded code maybe later

\ (backslash) is the namespace separator in PHP 5.3. A \ before the beginning of a function represents the Global Namespace. Putting it there will ensure that the function called is from the global namespace, even if there is a function by the same name in the current namespace

dmzoneill avatar Feb 22 '19 20:02 dmzoneill