Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help

by Corion (Pope)
on Apr 09, 2014 at 14:42 UTC ( #1081657=note: print w/ replies, xml ) Need Help??


in reply to Re^2: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
in thread PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help

Please don't modify your original code that much, as people then can't learn from seeing your code progress through the stages.

The next step would be to add (much) more amounts of server-side logging. print or warn at every step of the process. At least add logging statements to the following points:

mount '/echo' => SockJS->new( handler => sub { warn "Creating new session"; my ($session) = @_; $session->on( 'data' => sub { my $session = shift; warn "got new data"; $session->write('got your message'); warn "Wrote response"; } ); $session->write('connected'); warn "Wrote greeting"; my $w_cond = AnyEvent->condvar; my $w; $w = AnyEvent->timer( after => 0, interval => 5, cb => sub { undef $w; # cleanup $session->write('5 seconds have passed'); warn "Wrote timer message"; $w_cond->send(); } ); $w_cond->recv; warn "Leaving"; }; );


Comment on Re^3: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
Select or Download Code
Re^4: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
by xtpu2 (Acolyte) on Apr 09, 2014 at 15:29 UTC

    Sorry! I will stop doing that. So far, one of the issues has been resolved: the problem with connection closing immediately. The node with updated code is here.

    There is still a problem with the timer firing only once.

      Of course the timer fires only once, because we undef the timer in its callback. If you want to keep the timer running, you need to move its variable to somewhere that stays alive or never undef it in the callback.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1081657]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-09-21 07:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (167 votes), past polls