Hello!

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 '. ( 
$tx->res->message//join(':',@_)));
                          print 'Websocket (klines) closed '. 
join(':',@_),"\n";
                          Mojo::IOLoop->timer( 3 => sub {
                                                 $log->info('Restarting 
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 
hours.

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?

Alex.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to