J
JT
Hello, here is a really obscure problem (i think!) which is bound to
get the mind juices pumping!!
Basically i am implementing a Comet style methodology for streaming
data to the client over long lived http connections (apache & php
configured to support this). I have done my research and looked at the
following good articles/ initiatives:
1) http://groups.google.com/group/orbited-users/browse_thread/thread/e337ac03d0c9f13f#
2) http://cometdaily.com/2007/11/18/ie-activexhtmlfile-transport-part-ii/
3) I have also looked at how meteorserver (http://meteorserver.org)
works. BTW hats off to the meteoserver team, job well done i must
say..
OK I have the streaming working nicely (i am using IE 7), it will
stream for hours on end no problem if for what ever reason we
disconnect i have some nice reconnect logic in place; eventually i
will also implement heartbeats etc..
The data that i am streaming i am displaying in a Grid. I have created
a very nice Grid class using DIVs, i also use mouse events to detect
DIV boundaries so the user can resize the Grid or individual columns
as they see fit etc..
As soon as the user clicks on a column to resize the streaming stops.
However neither is the onLoad event called in the iframe html body or
neither is the tcp/ip socket to the server broken. I confirm this by
looking at the apache logs which tell me that the connection is still
open. Further to that, according to Ethereal (WinPCAP) the server is
still flushing script tags to the client!! Yet those script tags are
not being executed and the onLoad method has not been called!! Then
after this the Web Server (Apache 2.2 compiled on Win32) becomes
completely unusable, and for sometime it will not accept anymore
connections on it's listening port, then it seams to recover itself
(when the client is killed) and sometimes it cannot recover and dies
with a Segmentation Fault!!!
My code is as follows:
function initMarketStream()
{
try
{
htFile = new ActiveXObject("htmlfile");
htFile.open();
htFile.write("<html><iframe src=\""+url+"\"></iframe></html>");
htFile.parentWindow.cb = function(resp)
{
window.status="r " + (new Date()) + " " + resp;
handleMarketStream(resp);
}
htFile.parentWindow.rc = function()
{
htFile= null;
if(typeof CollectGarbage == "function") CollectGarbage();
window.status="recon at: " + (new Date());
setTimeout( 'initMarketStream();', 100);
}
htFile.close();
setInterval( function () {}, 10000);
}
catch(e)
{
}
}
The html i send to the iframe looks like this:
<?
print str_repeat(" ",1060);
print "<html><head><meta http-equiv=\"Content-Type\" content=\"text/
html; charset=utf-8\">";
print "<script>window.onError = null;</script>";
print "</head>";
print "<body onload=\"parent.rc();\">";
while( GetSomeData($dat) ) //is a well behaved waiting function
{
print "<script>parent.cb(\"".($dat)."\");</script>\n";
ob_flush();
flush();
}
?>
The colomn resize logic is basically some javascript handlers on Mouse
Down/Up/Move events which manulplate the elements/ objects in the
document:
Basically the resize works by a handler on the highest bubbled
mousemove event which detects when a DIV boundry exists and the resize
the DIV in accordance with the mouse cordinates if the button is
prest. The javascript routines which are used include: childNodes,
tagName, offsetWidth/ Height etc.., cursor, style objects, parentNode,
getAttribute, event object, we also use some global variables to
mentain state..
I really can't see how manipulating the DOM on the main document,
causes the ActiveX htmlfile to go into a deep unknown void which
nearly brings the web server to its knees!!!
Sorry for the long post guys, but any ideas would be appreciated.
get the mind juices pumping!!
Basically i am implementing a Comet style methodology for streaming
data to the client over long lived http connections (apache & php
configured to support this). I have done my research and looked at the
following good articles/ initiatives:
1) http://groups.google.com/group/orbited-users/browse_thread/thread/e337ac03d0c9f13f#
2) http://cometdaily.com/2007/11/18/ie-activexhtmlfile-transport-part-ii/
3) I have also looked at how meteorserver (http://meteorserver.org)
works. BTW hats off to the meteoserver team, job well done i must
say..
OK I have the streaming working nicely (i am using IE 7), it will
stream for hours on end no problem if for what ever reason we
disconnect i have some nice reconnect logic in place; eventually i
will also implement heartbeats etc..
The data that i am streaming i am displaying in a Grid. I have created
a very nice Grid class using DIVs, i also use mouse events to detect
DIV boundaries so the user can resize the Grid or individual columns
as they see fit etc..
As soon as the user clicks on a column to resize the streaming stops.
However neither is the onLoad event called in the iframe html body or
neither is the tcp/ip socket to the server broken. I confirm this by
looking at the apache logs which tell me that the connection is still
open. Further to that, according to Ethereal (WinPCAP) the server is
still flushing script tags to the client!! Yet those script tags are
not being executed and the onLoad method has not been called!! Then
after this the Web Server (Apache 2.2 compiled on Win32) becomes
completely unusable, and for sometime it will not accept anymore
connections on it's listening port, then it seams to recover itself
(when the client is killed) and sometimes it cannot recover and dies
with a Segmentation Fault!!!
My code is as follows:
function initMarketStream()
{
try
{
htFile = new ActiveXObject("htmlfile");
htFile.open();
htFile.write("<html><iframe src=\""+url+"\"></iframe></html>");
htFile.parentWindow.cb = function(resp)
{
window.status="r " + (new Date()) + " " + resp;
handleMarketStream(resp);
}
htFile.parentWindow.rc = function()
{
htFile= null;
if(typeof CollectGarbage == "function") CollectGarbage();
window.status="recon at: " + (new Date());
setTimeout( 'initMarketStream();', 100);
}
htFile.close();
setInterval( function () {}, 10000);
}
catch(e)
{
}
}
The html i send to the iframe looks like this:
<?
print str_repeat(" ",1060);
print "<html><head><meta http-equiv=\"Content-Type\" content=\"text/
html; charset=utf-8\">";
print "<script>window.onError = null;</script>";
print "</head>";
print "<body onload=\"parent.rc();\">";
while( GetSomeData($dat) ) //is a well behaved waiting function
{
print "<script>parent.cb(\"".($dat)."\");</script>\n";
ob_flush();
flush();
}
?>
The colomn resize logic is basically some javascript handlers on Mouse
Down/Up/Move events which manulplate the elements/ objects in the
document:
Basically the resize works by a handler on the highest bubbled
mousemove event which detects when a DIV boundry exists and the resize
the DIV in accordance with the mouse cordinates if the button is
prest. The javascript routines which are used include: childNodes,
tagName, offsetWidth/ Height etc.., cursor, style objects, parentNode,
getAttribute, event object, we also use some global variables to
mentain state..
I really can't see how manipulating the DOM on the main document,
causes the ActiveX htmlfile to go into a deep unknown void which
nearly brings the web server to its knees!!!
Sorry for the long post guys, but any ideas would be appreciated.