Plater 7,872
Recognized Expert Expert
I am using the XMLHttpRequest to send a request every 5ish seconds or so.
Everything works fine until I take the server down that the object is trying to retrieve data from.
Then the firefox console keeps racking up these: -
uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)"
-
If I turn the server back on, it continues to update it's data just fine. I know a simple solution is to just trap the exception, but I don't think I should have to. There should be something I can do to keep it from generating one in the first place.
Relevant code: -
function createRequestObject()
-
{//creates an httprequest object
-
var ro;
-
-
var browser = navigator.appName;
-
if(browser == "Microsoft Internet Explorer"){
-
ro = new ActiveXObject("Microsoft.XMLHTTP");
-
}else{
-
ro = new XMLHttpRequest();
-
}
-
return ro;
-
}
-
-
var http = createRequestObject();
-
var ourinterval=setInterval("SendUpdate()",5000);
-
-
function SendUpdate()
-
{
-
http.open('get', '/refresh.cgi?time='+ new Date().getTime());
-
http.onreadystatechange = handleSendUpdateReponse;
-
http.send(null);
-
}
-
function handleSendUpdateReponse()
-
{
-
if(http.readyState == 4)
-
{
-
var update = new Array();
-
if (http.status=="200")
-
{
-
var response = http.responseText;
-
if (response!="")
-
{
-
if(response.indexOf('|' != -1))
-
{
-
update=response.split('|');
-
if (update.length>0)
-
{
-
if (update[1].indexOf("SUCCESS")>-1)
-
{
-
var line=update[1];
-
-
var things=new Array();
-
things=line.split('&');
-
var i;
-
for (i=0;i<things.length;i++)
-
{
-
var nameval=things[i].split('=');
-
if (i>0)
-
{
-
returnObjById(nameval[0]).innerHTML=nameval[1];
-
}
-
}
-
}//end of found "SUCCESS"
-
}//end of update split("|") to have multiple sections
-
}//end of response.indexof("|")
-
}//end of response!=""
-
}//end of status==200
-
}//end of readystate=4
-
}//end of function
-
2 36722 Plater 7,872
Recognized Expert Expert
Well, turns out that its something firefox just hasn't gotten around to fixing yet: http://www.fleegix.org/articles/2006..._failure-error
The activeX equiv of XMLHttpRequest does not have this problem, providing a much more usefull notification as "12029" in the http.status
Those error codes can be found here: http://support.microsoft.com/kb/193625
A lot of people use the XMLHTTPRequest object, why am I the only one doing checking for if the talkbalk host is no longer there?
Here are the changes I made to keep both browsers quiet and happy: -
function SendUpdate()
-
{
-
var action="DATETIME&TEMPERATURE&HUMIDITY&SAMPLESTATE";
-
action+="&CHAN1&CHAN2&CHAN3&CHAN4&CHAN5&CHAN6&CHAN7&CHAN8&CHAN9&CHAN10";
-
try
-
{
-
http.open('get', '/refresh.cgi?'+action+'&time='+ new Date().getTime());
-
http.onreadystatechange = handleSendUpdateReponse;
-
http.send(null);
-
}
-
catch(error)
-
{
-
//alert(error);
-
returnObjById("SAMPLESTATE").innerHTML="Problem Communicating";
-
}
-
-
}
-
-
function handleSendUpdateReponse()
-
{
-
if(http.readyState == 4)
-
{
-
var update = new Array();
-
if (http.status=="200")
-
{
-
var response = http.responseText;
-
if (response!="")
-
{
-
if(response.indexOf('|' != -1))
-
{
-
update=response.split('|');
-
if (update.length>0)
-
{
-
if (update[1].indexOf("SUCCESS")>-1)
-
{
-
var line=update[1];
-
-
var things=new Array();
-
things=line.split('&');
-
var i;
-
for (i=0;i<things.length;i++)
-
{
-
var nameval=things[i].split('=');
-
if (i>0)
-
{
-
returnObjById(nameval[0]).innerHTML=nameval[1];
-
}
-
}
-
}//end of found "SUCCESS"
-
}//end of update split("|") to have multiple sections
-
}//end of response.indexof("|")
-
}//end of response!=""
-
}//end of status==200
-
else if(http.status==12029)
-
{
-
returnObjById("SAMPLESTATE").innerHTML="Problem Communicating";
-
}
-
}//end of readystate=4
-
}//end of function
-
Hi.
I also had a though time figure out a way to make this happen in firefox. -
//////////////////////////////////////////////////////////////////////////////////////////////
-
// firefox reports uncaught exception NS_ERROR_FAILURE with nsIXMLHttpRequest.send
-
// http://bytes.com/forum/thread681905.html
-
// http://radio.javaranch.com/pascarello/2006/02/07/1139345471027.html
-
// http://dev.rubyonrails.org/ticket/4267
-
//
-
// I needed a way to track server downtime even if the callback does not work when
-
// server closes down. Since firefox does not support failover on server downtime I made this object
-
// where I track errors even if there is no callbacks to track.
-
//
-
// To use the object from your main app:
-
// failover = new clientFailover(); , create object in seperate "thread" (unsing setInterval)
-
// failover.start("fail.php"); , the url where the request is made against as parameter
-
// object that handles failover between client and server. It pings the server in smal intervals
-
// and reporttext is generated every 10 seconds. Let me know if anyone comes up with a better solution
-
-
//////////////////////////////////////////////////////////////////////////////////////////////
-
function clientFailover(){
-
var start,url,frequest;
-
var uinterval = 10000; // set update interval
-
var pinterval = 1000; // set ping interval
-
var intervalID = 0;
-
var fstatus = false; // true on error, false on normal operation
-
var active = false; // flag on when thread is aktiv
-
var errorflag = 0;
-
-
// Set error value code, 0 = connection and callback ok, 1 = connection ok but status error
-
// 2 = connection ok but page error, 4 = Connection and callback lost
-
var setError = function(value){
-
errorflag = value;
-
};
-
-
var getError = function(){
-
return errorflag;
-
};
-
-
// cObject is the XMLHTTPRequest instance
-
var cObject = function(){
-
var conn = false;
-
if (window.XMLHttpRequest){
-
conn = new XMLHttpRequest();
-
}else if (window.ActiveXObject){
-
try{
-
conn = new ActiveXObject("Msxml2.XMLHTTP");
-
}catch (e){
-
try{
-
conn = new ActiveXObject("Microsoft.XMLHTTP");
-
}catch (e){
-
conn = false;
-
}
-
}
-
}
-
return conn;
-
}
-
// start method, this method is called from the main application
-
// Parameter is the URL, This is where the "ping" is making request against
-
-
this.start = function(value){
-
-
url = value;
-
frequest = cObject();
-
if (!frequest || !url){
-
return false;
-
}else{
-
-
ping();
-
// set interval for the update info (every 10 second), this should be higher than the ping interval
-
setInterval(function(){
-
pushInfo();}
-
,uinterval);
-
-
return true;
-
}
-
};
-
var pushInfo = function(){
-
if (getError() == 4){
-
alert("Server and callback down " + getError());
-
}else{
-
alert("Server and callback works " + getError());
-
}
-
};
-
-
// request (ping) the url page on server. The ping interval is set to one second
-
var ping = function(){
-
-
intervalID = setInterval(function(){
-
setError(4);
-
frequest.onreadystatechange = check;
-
frequest.open("GET", url, true);
-
try{
-
frequest.send(null);
-
-
}catch (e){
-
// catch NS_ERROR_NOT_INITZIALIZED
-
}
-
}, pinterval);
-
-
}
-
// Check if the request return anything, if so, set status to true meaning that server is down
-
var check = function(){
-
-
try{
-
if (frequest.readyState >= 1){
-
-
if (frequest.status !=200){
-
-
fstatus = true;
-
setError(2);
-
}else{
-
fstatus = false;
-
setError(0);
-
}
-
}
-
}catch (e){
-
setError(4);
-
// firefox reports uncaught exception NS_ERROR_FAILURE with nsIXMLHttpRequest.send
-
// this failure is catched here
-
}
-
-
};
-
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: meaneyedcat |
last post by:
When I call addField(), my table appears to be populated correctly
with a new row in the table with all the required fields. However,
when I call delete row on any new rows that have been created, I get
the following error:
Error: uncaught exception: " nsresult: "0x80004002
(NS_NOINTERFACE)" location: "JS frame ::
http://localhost:3000/form/edit_fields/1 :: removeField :: line 65"
data: no]
|
by: harishdixit1 |
last post by:
Hello friends i m calling a javascript function from toolbar on the web
page .
but on statement xmlHTTPReq.send( data );
exception occurs. execption is
"Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED)
" nsresult: "0xc1f30001
(NS_ERROR_NOT_INITIALIZED)"
|
by: -Lost |
last post by:
Error: uncaught exception: " nsresult: "0x80004001
(NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame ::
file:///D:/sites/_test/js/iterate_document.htm :: <TOP_LEVEL:: line 15" data: no]
Line 15 being:
s += j + ". " + i + ": " + document + "<br />\n";
All the code:
|
by: mkoonani |
last post by:
Hi, i am getting the following error while using js to communicate between parent and child windows using Firefox browser.
Can anyone help me out from this.?
MK
|
by: funktacular |
last post by:
Hi -
I have some javascript that works when I run it from a server, but I
need to run it locally. When I try to execute it locally I get the
following error:
Error: uncaught exception: Permission denied to get property
Window.processXML
Is there a way to get around this issue?
default.htm
| |
by: xhunter |
last post by:
Hi,
I have written my code to load some content through ajax, which works perfectly,
then I thought of adding a timeout to retry the action in case it has failed or something.
here is the code :
var requestTimer = setTimeout(function() {
xmlHttp.send(post);
}, 10000);
|
by: josephx |
last post by:
Hello,
I got some of these errors listed below after executing an HTTP Post MIDlet on CLDC/MIDP platform, "Nokia S40 DP 2.0 SDK 1.1" and "S40 5th Edition SDK Feature Pack 1" and even for S60's SDK.. the application stops.
However, it does work only on "Sun Java(TM) Wireless Toolkit 2.5.1 for CLDC" with the same errors displayed, but the application was able to execute successfully.
Errors received are:
Using Untrusted simulated domain...
|
by: friend |
last post by:
Error: uncaught exception: " nsresult:
"0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
http://manimekalai/VulnMgmt/scanfi/crs_source/vulnupdate/latest.php?vulnerability=2451
:: centrePopup :: line 22" data: no]
how to coorect thus the above error...........
|
by: smohan |
last post by:
Hi,
I'm very new to perl. I tried to use the perl module in php script, but im getting error
<?php
$perl = new Perl();
$perl->eval("BEGIN {unshift( @INC, '/opt/otrs');}");
$perl->eval('use Kernel::System::Email qw(new Send ConfigObject LogObject DBObject TimeObject MainObject EncodeObject _MessageIDCreate Log Get); ');
$ar=array(From => 'me@example.com',
To => 'friend@example.com',
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |