Just another Perl shrine | |
PerlMonks |
real-time output from Mojolicious WebSockets?by BroFish (Initiate) |
on Dec 19, 2014 at 02:58 UTC ( [id://1110800]=perlquestion: print w/replies, xml ) | Need Help?? |
BroFish has asked for the wisdom of the Perl Monks concerning the following question: Hello all. I am building a web app that will run compliance checks on client-submitted files placed in a special directory. These checks can run for more than a minute, and I want the output from those checks to be displayed in the web browser as they are generated...not waiting to the end of the run. The non-blocking Mojolicious server and WebSockets seem like a good solution technique. In the following code, &myapp() simulates the long running checks, occasionally producing output. The good news is the desired output appears in the web browser, that output being "Connection open. Entering log4. Entering myapp. 0... 1... 2... 3... Leaving myapp. Leaving log4." The problem is the web browser sits idle for 12 seconds, and then the output displays all at once. Instead, I would like the output to appear in the web browser as soon as $tx->send() is called. How can that be accomplished with Mojolicious? Tcpdump shows the web server is sending the output all at once, not as $tx->send() is called. Here is the complete, running code (in one file):
This code is running on CentOS 6.5, Perl 5.10.1 with these perl modules: EV 4.18; IO::Socket::Sockets 0.65; IO::Socket::SSL 2.007. Thank you very much for your insight and patience.
Back to
Seekers of Perl Wisdom
|
|