i’m a bit confused about the reason it does not work in Firefox when it works in other(all) browsers.
Initializing EventSource and registering a listener:
var output = new EventSource('/subscribe');
output.addEventListener('shell_stream', function(e) {
$('#shell-output').append(e.data + "<br/>");
}, false);
Then on page loading i’m looking through query string and if there is a file and the run action, i’m sending them to server(via ajax) and the server sending back the data to the listener registered above.
Debugged the script a lot.
It does send request and receive valid response, and server for sure sending data to listener.
However, on Firefox, the listener does not react in any way.
Worth to note what the listener works perfect if the user click Run button, which calls exactly the same function which is called on page load if file and run found in query string.
Also, if I fire an alert() on page load and user click it, the listener will work!
Here is the live link to try in various browsers:
http://cibox.org/slivu/stackoverflow?file=extract-image.rb&run=true
Thank you.
Final Update
moved this to a separate post:
https://stackoverflow.com/questions/13159977
=== UPDATE ===
forgot/missed that
onopenis called every N seconds 🙂so my file were running forever 🙂
using a ugly hack for now:
initializedmake sure it will run only once.found it!
my code looks like this:
the interesting part is that on all browsers connection is already established when
invoke_file_runneris executed.except firefox, where connection is established afterward.
no idea how and why.
the fix is simple:
this will ensure the
invoke_file_runneris executed only after connection established.