amphp / websocket-client

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

The request was not processed and can be safely retried #43

Closed RoodFruit closed 4 months ago

RoodFruit commented 2 years ago

Hi,

All of a sudden we're receiving the error "The request was not processed and can be safely retried.". Until now, everything worked perfectly.

Anybody got an idea of what the error means?

Info

Code:

\Amp\Loop::run(
    function () {
        $handshake = new \Amp\Websocket\Client\Handshake('wss://...');

        while (true) {
            try {
                $connection = yield connect($handshake);

                yield $connection->send(json_encode([...subscription_info...]));

                while ($message = yield $connection->receive()) {
                    // ...
                }
            } catch (Exception $e) {
                // ...
            }
        }
    }
);

Stack trace:

Error reads: The request was not processed and can be safely retried.

Trace: #0 [internal function]: Amp\Http\Client\Connection\DefaultConnectionFactory->Amp\Http\Client\Connection\{closure}()
#1 ../vendor/amphp/amp/lib/Coroutine.php(115): Generator->throw(Object(Amp\Socket\TlsException))
#2 ../vendor/amphp/amp/lib/Failure.php(33): Amp\Coroutine->Amp\{closure}(Object(Amp\Socket\TlsException), NULL)
#3 ../vendor/amphp/amp/lib/Internal/Placeholder.php(143): Amp\Failure->onResolve(Object(Closure))
#4 ../vendor/amphp/amp/lib/Internal/Placeholder.php(177): Amp\Coroutine->resolve(Object(Amp\Failure))
#5 ../vendor/amphp/amp/lib/Coroutine.php(137): Amp\Coroutine->fail(Object(Amp\Socket\TlsException))
#6 ../vendor/amphp/amp/lib/Failure.php(33): Amp\Coroutine->Amp\{closure}(Object(Amp\Socket\TlsException), NULL)
#7 ../vendor/amphp/amp/lib/Internal/Placeholder.php(143): Amp\Failure->onResolve(Object(Closure))
#8 ../vendor/amphp/amp/lib/Internal/Placeholder.php(177): Amp\Promise@anonymous->resolve(Object(Amp\Failure))
#9 ../vendor/amphp/amp/lib/Deferred.php(66): Amp\Promise@anonymous->fail(Object(Amp\Socket\TlsException))
#10 ../vendor/amphp/socket/src/Internal/functions.php(148): Amp\Deferred->fail(Object(Amp\Socket\TlsException))
#11 ../vendor/amphp/amp/lib/Loop/NativeDriver.php(327): Amp\Socket\Internal\{closure}('ac', Resource id #1219, Object(Amp\Deferred))
#12 ../vendor/amphp/amp/lib/Loop/NativeDriver.php(127): Amp\Loop\NativeDriver->selectStreams(Array, Array, 4.625)
#13 ../vendor/amphp/amp/lib/Loop/Driver.php(138): Amp\Loop\NativeDriver->dispatch(true)
#14 ../vendor/amphp/amp/lib/Loop/Driver.php(72): Amp\Loop\Driver->tick()
#15 ../vendor/amphp/amp/lib/Loop.php(95): Amp\Loop\Driver->run()
...
trowski commented 1 year ago

Based on the exception stack containing a TlsException there may be an error with the server you're connecting to. Use UnprocessedRequestException::getPrevious() to get the previous exception.