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

Exception not reaching outer try catch #33

Open
programmin1 opened this issue May 12, 2021 · 2 comments
Open

Exception not reaching outer try catch #33

programmin1 opened this issue May 12, 2021 · 2 comments

Comments

@programmin1
Copy link

I put the whole Loop doing a websocket in a try... catch( Exception $e ) {

If there is a problem, like I disconnect internet, I get...

   Amp\Websocket\ClosedException  : Connection closed abnormally while awaiting message; Code 1008 (POLICY_VIOLATION); Reason: "Exceeded unanswered PING limit"

  at .../vendor/amphp/websocket/src/Rfc6455Client.php:659
    655|                             $deferred->resolve();
    656|                             break;
    657| 
    658|                         default:
  > 659|                             $deferred->fail(new ClosedException(
    660|                                 'Connection closed abnormally while awaiting message',
    661|                                 $code,
    662|                                 $reason
    663|                             ));

  Exception trace:

  1   Amp\Websocket\Rfc6455Client::Amp\Websocket\{closure}()
      [internal]:0

  2   Generator::current()
      .../vendor/amphp/amp/lib/Coroutine.php:67

How can I catch error and retry since try/catch does not work?

@kelunik
Copy link
Member

kelunik commented May 12, 2021

How does your code look like?

@programmin1
Copy link
Author

The same way the example on your front page works:

Loop::run(function () { ...

$connection = yield connect('wss://...')....

while ($message = yield $connection->receive()) { ...

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

No branches or pull requests

2 participants