amphp / websocket-client

Async WebSocket client for PHP based on Amp.
https://amphp.org/websocket-client
MIT License
148 stars 18 forks source link

Fatal Error in Rfc6455Connection due to not implementing method #28

Closed dfelton closed 3 years ago

dfelton commented 3 years ago

Error:

Fatal error: Class Amp\Websocket\Client\Rfc6455Connection contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Amp\Websocket\Client::didPeerInitiateClose) in vendor/amphp/websocket-client/src/Rfc6455Connection.php on line 15

Call Stack (amphp code starts at line 8, paths abbreviated to root of project):

0.0055     465472   1. {main}() /bin/gemini:0
0.0737    5438352   2. Symfony\Component\Console\Application->run(???, ???) /bin/gemini:340
0.0794    5754736   3. Symfony\Component\Console\Application->doRun(???, ???) /vendor/symfony/console/Application.php:149
0.0807    5758496   4. Symfony\Component\Console\Application->doRunCommand(???, ???, ???) /vendor/symfony/console/Application.php:273
0.0808    5758496   5. Kobens\Gemini\Command\Command\Market\BookKeeper->run(???, ???) /vendor/symfony/console/Application.php:1009
0.0816    5759952   6. Kobens\Gemini\Command\Command\Market\BookKeeper->execute(???, ???) /vendor/symfony/console/Command/Command.php:255
0.0823    5799112   7. Kobens\Gemini\Api\WebSocket\MarketData\BookKeeper->openBook() /src/Command/Command/Market/BookKeeper.php:45
0.0854    6161264   8. Amp\Loop::run(???) /src/Api/WebSocket/MarketData/BookKeeper.php:30
0.0856    6171784   9. Amp\Loop\NativeDriver->run() /vendor/amphp/amp/lib/Loop.php:84
0.3095    8750800  10. Amp\Loop\NativeDriver->tick() /vendor/amphp/amp/lib/Loop/Driver.php:72
0.3095    8750880  11. Amp\Loop\NativeDriver->dispatch(???) /vendor/amphp/amp/lib/Loop/Driver.php:134
0.3096    8750880  12. Amp\Loop\NativeDriver->selectStreams(???, ???, ???) /vendor/amphp/amp/lib/Loop/NativeDriver.php:97
0.3621    8751408  13. Amp\ByteStream\ResourceInputStream::Amp\ByteStream\{closure:/vendor/amphp/byte-stream/lib/ResourceInputStream.php:70-102}(???, ???, ???) /vendor/amphp/amp/lib/Loop/NativeDriver.php:192
0.3623    8751632  14. Amp\Deferred->resolve(???) /vendor/amphp/byte-stream/lib/ResourceInputStream.php:101
0.3623    8751632  15. {anonymous-class:/vendor/amphp/amp/lib/Deferred.php:20-25}->resolve(???) /vendor/amphp/amp/lib/Deferred.php:45
0.3623    8751632  16. Amp\Coroutine->Amp\{closure:/vendor/amphp/amp/lib/Coroutine.php:79-135}(???, ???) /vendor/amphp/amp/lib/Internal/Placeholder.php:130
0.3623    8751632  17. Generator->send(???) /vendor/amphp/amp/lib/Coroutine.php:105
0.3623    8751632  18. Amp\Http\Client\Connection\Http1Connection->readResponse(???, ???, ???, ???) /vendor/amphp/amp/lib/Coroutine.php:105
0.3638    8804184  19. Amp\Http\Client\Connection\Http1Connection->handleUpgradeResponse(???, ???, ???) /vendor/amphp/http-client/src/Connection/Http1Connection.php:322
0.3640    8879880  20. Amp\asyncCall(???, ...variadic()) /vendor/amphp/http-client/src/Connection/Http1Connection.php:474
0.3640    8879880  21. Amp\call(???, ...variadic()) /vendor/amphp/amp/lib/functions.php:91
0.3641    8880568  22. Amp\Coroutine->__construct(???) /vendor/amphp/amp/lib/functions.php:66
0.3641    8880568  23. Generator->current() /vendor/amphp/amp/lib/Coroutine.php:60
0.3641    8880568  24. Amp\Http\Client\Connection\Http1Connection::Amp\Http\Client\Connection\{closure:/vendor/amphp/http-client/src/Connection/Http1Connection.php:466-474}() /vendor/amphp/amp/lib/Coroutine.php:60
0.3641    8880568  25. Amp\call(???, ...variadic(???, ???, ???)) /vendor/amphp/http-client/src/Connection/Http1Connection.php:468
0.3641    8880944  26. Amp\Websocket\Client\Rfc6455Connector::Amp\Websocket\Client\{closure:/vendor/amphp/websocket-client/src/Rfc6455Connector.php:55-77}(???, ???, ???) /vendor/amphp/amp/lib/functions.php:60
0.3641    8880944  27. Amp\Websocket\Client\Rfc6455ConnectionFactory->createConnection(???, ???, ???, ???) /vendor/amphp/websocket-client/src/Rfc6455Connector.php:76
0.3657    9040408  28. spl_autoload_call(???) /vendor/amphp/websocket-client/src/Rfc6455ConnectionFactory.php:20
0.3657    9040472  29. Composer\Autoload\ClassLoader->loadClass(???) /vendor/amphp/websocket-client/src/Rfc6455ConnectionFactory.php:20
0.3658    9040600  30. Composer\Autoload\includeFile(???) /vendor/composer/ClassLoader.php:322
0.3659    9054808  31. include('/vendor/amphp/websocket-client/src/Rfc6455Connection.php') /vendor/composer/ClassLoader.php:444

Closure being passed to \Amp\Loop::run():

private function getRunClosure(): \Closure
{
    $websocketUrl = $this->getWebSocketUrl();
    return function () use ($websocketUrl) {
        $connection = yield \Amp\Websocket\Client\connect($websocketUrl);
        while ($message = yield $connection->receive()) {
            $payload = yield $message->buffer();
            // code not relevant to issue...
        }
    };
}

Any assistance would be greatly appreciated. My application has version 173b54137cdcd4288702f615f05c1029e613ba37 installed (release 1.0.0).

Thank you in advance.

kelunik commented 3 years ago

Looks like you have an old version of amphp/websocket installed? https://github.com/amphp/websocket/releases/tag/v1.0.0

dfelton commented 3 years ago

Interesting. You're correct amphp/weboscket was out of date even after I had performed a composer upgrade amphp/websocket-client (finally moving from dev-master to 1.0.0 for amphp/websocket-client).

composer show | grep amphp/websocket
amphp/websocket                     v1.0.0-rc1         Shared code for websocket servers and clients.
amphp/websocket-client              v1.0.0             Async WebSocket client for PHP based on Amp.

After performing a composer upgrade amphp/websocket I am now on v1.0.0, and things are working correctly.

Thank you this has brought to light that I should be monitoring other dependency packages more closely for potential upgrades, even when not included via the root of my project.