You need to sign in to do that
Don't have an account?
Nashorn
how to know if sfdc services are available, without using the sfdc api
I need to know how to determine if the salesforce services are available, perferably without using the salesforce API itself (i.e. without SforceServiceLocator, LoginResult, etc).
I am reasoning that since the salesforce API uses Web Services, which are based on HTTP, then it is reasonable to assume that if
https://www.salesforce.com/login.jsp
does not return anything then that means that the salesforce Web Services are also not available.
I am also basing this theory on the fact that one time I was trying to use the DataLoader and kept getting some kind of connection error (it said "PartnerClient connection error" or something like that). When I went to
https://www.salesforce.com/login.jsp
it was also unavailable. About 10 minutes later the DataLoader was able to connect ok, and I was also able to retrieve a page from
https://www.salesforce.com/login.jsp,
which makes me think that it is a reasonable assumption.
So basically, I am hoping that I can get away with doing something simple like this:
//test if sfdc web services are available
try {
URL url = new URL("https://www.salesforce.com/login.jsp");
URLConnection conn = url.openConnection();
/**
* Check if the value of the first header value is null (if
* everything is ok then it should be something like "HTTP/1.1 200
* OK")
*/
String headerName = conn.getHeaderFieldKey(0);
String headerValue = conn.getHeaderField(0);
if (headerValue != null) {
//success
} else {
//failure
}
conn = null;
} catch (Exception e) {
//exception
}
The only question I have is if this will always correctly tell me if the salesforce services are available.
Thanks for any help!
I am reasoning that since the salesforce API uses Web Services, which are based on HTTP, then it is reasonable to assume that if
https://www.salesforce.com/login.jsp
does not return anything then that means that the salesforce Web Services are also not available.
I am also basing this theory on the fact that one time I was trying to use the DataLoader and kept getting some kind of connection error (it said "PartnerClient connection error" or something like that). When I went to
https://www.salesforce.com/login.jsp
it was also unavailable. About 10 minutes later the DataLoader was able to connect ok, and I was also able to retrieve a page from
https://www.salesforce.com/login.jsp,
which makes me think that it is a reasonable assumption.
So basically, I am hoping that I can get away with doing something simple like this:
//test if sfdc web services are available
try {
URL url = new URL("https://www.salesforce.com/login.jsp");
URLConnection conn = url.openConnection();
/**
* Check if the value of the first header value is null (if
* everything is ok then it should be something like "HTTP/1.1 200
* OK")
*/
String headerName = conn.getHeaderFieldKey(0);
String headerValue = conn.getHeaderField(0);
if (headerValue != null) {
//success
} else {
//failure
}
conn = null;
} catch (Exception e) {
//exception
}
The only question I have is if this will always correctly tell me if the salesforce services are available.
Thanks for any help!
Message Edited by Nashorn on 04-04-2006 03:10 AM
First, each of the 4 SFDC instances (na1, emea, jp, and ssl) can operate independantly of the main website (www) being online/offline. Even if the API servers (na1-api) are down, API access may still be available by repointing to na1 itself.
Even a login page failure (as with the other day) has workarounds. Instead of logging in at https://www.salesforce.com/login.jsp you can go to the instance-specific page at https://na1.salesforce.com/ to log in there.
The same can be done with the API, much like you redirect the binding URL after a successful login, you can also redirect it to your instance-specific server URL before a login.
Lastly, the definition of up/down is a little more grey. Do you consider "available" being both API/UI? (Is the API critical to your platform usage?) What if the UI were up, but API down, or the other way around? What if everything but search were working? etc.
... Just some things to keep in mind
Salesforce Heretic Blog
Message Edited by daroz on 04-04-2006 08:23 AM
To give a better description of what I am actually trying to do, I am calling the DataLoader command line program from a Java program as an external process. I need to be able to handle any connection problems that the DataLoader has (sfdc service not available, connection broken, etc). I have decided that I will parse the DataLoader's log4j output in order to see if there are any connection errors. The only problem now is that I don't have a complete list of all error messages that resul from a connection problem.
At the moment I am searching through every multi-line DataLoader log statement that begins with "ERROR." If I find the string "connect" somewhere inside of it then I am assuming that there was a connection error.
I know that this is a crude method, but at the present time I don't know which error messages I have to look out for.
If anyone has any hints as to what error messages I have to look out for regarding a connection problem it would be greatly appreciated!
As far as s complete listing of error codes. I'm not sure. I think some may be generated by the underling sockets code, and/or the Apache Commons HTTP client. (It's been awhile since I looked at that code base, sorry.)
String strRegexException = "(java.net.UnknownHostException)|(ConnectionTimeoutException)";
I am not that familiar with using the Salesforce API yet, so if anyone has any suggestions for other exceptions that I have to watch out for then it would be a big help. In the meantime I will sift through the DataLoader source and see what I can find.