widdgetz
08-08-2007, 04:27 PM
I am developing a chat server based on Perl designed to push events (JS commands) back to the browser for real-time updates and reduced server load from polling. Currently I am at a dead stop with IE. I am using the Comet implementation from this page: http://empireenterprises.com/_comet.html
I am looking for anyone who knows why IE is not executing the Javascript commands sent by the server (alert('a' + 0) for example) when they are loaded in an iframe (and even when they are not loaded in an iframe) - I am fairly certain that this is how Comet is supposed to work, please correct me if I am wrong.
The browser connects to the push server via a long-lived XMLHTTPRequest (Firefox/Opera) or an htmlfile ActiveXObject (IE) as seen in the example. The server stores the HTTP browser socket connection and sends commands back to it for each of the chat channels that it is subscribed to. This works fine in Opera and Firefox, but IE does not handle the streaming properly.
I have attached a very simple, self-contained, and well-documented implementation of the push technology used at the link above. The script is a simple Perl HTTP server listening on port 9090 (this is a very simple mimic of the environment of my actual application). The primary difference is that my server is an HTTP server, not a mod_perl script (using persistent Apache connections for this application is not acceptable). Here are my instructions and what to look out for:
Once the Perl command line is running the attached script (you may want to rename from .txt to .pl first), connect to http://localhost:9090 in Firefox. The Perl HTTP server will print the page which will then connect back to the HTTP server (via http://localhost:9090/?comet) and stream the content. The content generated by the server is three simple alert() calls which each include a 'a', 'b', or 'c' and random number for reference, these are also shown in the server command line. Firefox will print these messages as they are generated by the server, but IE will not print them until the server closes the socket and the full DOM has been constructed.
The most curious thing I have found is that if you go to http://localhost:9090/?comet in IE, the first time the alert()s will not show up until the script has finished. However, if you refresh the page, the alert()s will come in at the proper time. I am hoping that this is a good signal to someone of what I am doing wrong.
Have I implemented this sample HTTP server incorrectly? Am I printing something wrong? Am I completely off track?
I've tried using $client->send() instead of print $client, sending w/ and w/o endlines, sending the OK header and not, sending <html><body> before the script tags, along with many other miscellaneous ideas and combinations, but maybe just not quite the right one.
Many thanks to anyone who can take a look at this and help figure out the problem!
- Ian Paterson
I am looking for anyone who knows why IE is not executing the Javascript commands sent by the server (alert('a' + 0) for example) when they are loaded in an iframe (and even when they are not loaded in an iframe) - I am fairly certain that this is how Comet is supposed to work, please correct me if I am wrong.
The browser connects to the push server via a long-lived XMLHTTPRequest (Firefox/Opera) or an htmlfile ActiveXObject (IE) as seen in the example. The server stores the HTTP browser socket connection and sends commands back to it for each of the chat channels that it is subscribed to. This works fine in Opera and Firefox, but IE does not handle the streaming properly.
I have attached a very simple, self-contained, and well-documented implementation of the push technology used at the link above. The script is a simple Perl HTTP server listening on port 9090 (this is a very simple mimic of the environment of my actual application). The primary difference is that my server is an HTTP server, not a mod_perl script (using persistent Apache connections for this application is not acceptable). Here are my instructions and what to look out for:
Once the Perl command line is running the attached script (you may want to rename from .txt to .pl first), connect to http://localhost:9090 in Firefox. The Perl HTTP server will print the page which will then connect back to the HTTP server (via http://localhost:9090/?comet) and stream the content. The content generated by the server is three simple alert() calls which each include a 'a', 'b', or 'c' and random number for reference, these are also shown in the server command line. Firefox will print these messages as they are generated by the server, but IE will not print them until the server closes the socket and the full DOM has been constructed.
The most curious thing I have found is that if you go to http://localhost:9090/?comet in IE, the first time the alert()s will not show up until the script has finished. However, if you refresh the page, the alert()s will come in at the proper time. I am hoping that this is a good signal to someone of what I am doing wrong.
Have I implemented this sample HTTP server incorrectly? Am I printing something wrong? Am I completely off track?
I've tried using $client->send() instead of print $client, sending w/ and w/o endlines, sending the OK header and not, sending <html><body> before the script tags, along with many other miscellaneous ideas and combinations, but maybe just not quite the right one.
Many thanks to anyone who can take a look at this and help figure out the problem!
- Ian Paterson