uperl / AnyEvent-WebSocket-Client

WebSocket client for AnyEvent
9 stars 10 forks source link

On finish callback never called #53

Open robinvrd opened 4 years ago

robinvrd commented 4 years ago

I am using the AnyEvent WebSocket Client with a websocket server set up on Java server Payara. I am using this server for websocket with javascript clients on another use case and everything is working fine.

Here, sending/receiving messages is working fine, but my problem comes from on finish callback which is never called when my server shut down.

    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;

Am I doing something wrong here ?