Some questions (maybe stupid) on websockets
(too old to reply)
Alex Povolotsky
2018-09-25 06:29:59 UTC

I need a bit of help on websockets.

I'm writing an app which should open several websocket connections with
similar handling. With one websocket it worked perfectly, but with two I've
run into problems.

It look like when one connection is being reset by server, my restart
mechanism sometimes fails.

I'm using one UserAgent for both connections (is it right?) and I've
implemented reconnect as

$tx->on( finish => sub {
my $tx = shift;
$log->info('Websocket (klines) closed '. (
print 'Websocket (klines) closed '.
Mojo::IOLoop->timer( 3 => sub {
after 3 seconds');

app->events->emit('klines_connect', $url);
} );
} );

where klines_connect performs websocket connection.

For some reason, I'm getting several finish events in a row (according to
my log at least) and no restart pause. After several attempts, everything
hangs until Ctrl-C.

I cannot reliable reproduce the problem, it just happens after several

Assuming I have several websocket connection with common error and finish
event handlers and just different json one, can someone please show me good
impelmentation on writing well-reusable code for making handlers?

You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive: