AnyEvent::WebSocket::Client finish callback not called

189 views Asked by At

I am having issue using AnyEvent::WebSocket::Client. The send/receive system works well, but I want to use the on finish callback to handle connection closure but it is never called.

my $client = AnyEvent::WebSocket::Client->new;

$client->connect("ws://...")->cb(sub {
    our $connection = eval { shift->recv };

    if ($@) {
        warn $@;
        return;
    }

    $connection->on(each_message => sub {
        ...
    });

    $connection->on(finish => sub {
        print "Connection finished\n";
    });
});

AnyEvent->condvar->recv;

I want the client to try to reconnect when the connection is terminating, but the on finish callback is never called when I shut down my websocket server.

Any help would be great !

0

There are 0 answers