Below is an example of a robust script which contacts www.example.com and retries up to 4 if the initial connection fails. It also logs the different types of connection failures. The following are different types of problems that this script will help mitigate:
- A low level networking problem (Eg lost TCP packets during the handshake which sets up the initial connection)
- An HTTP time out (Eg the application server being contacted took too long responding or stopped responding)
- An invalid URL being used
- SuiteScript taking too long to execute
- The SuiteScript usage limit being exceeded
This doesn't guarantee that there will not be problems connecting to a 3rd party server but it will greatly increase the rate of success.
If other HTTP headers besides status code 200 are acceptable then add them as well in the else if statement below (Eg 204 No Content - which indicates that the server has received the request but is returning no content).
Disclaimer: The sample code described herein is provided on an"as is" basis, without warranty of any kind, to the fullest extentpermitted by law. NetSuite Inc. does not warrant or guarantee the individualsuccess developers may have in implementing the sample code on theirdevelopment platforms or in using their own Web server configurations.
NetSuite Inc.does not warrant, guarantee or make any representations regarding the use,results of use, accuracy, timeliness or completeness of any data or informationrelating to the sample code. NetSuite Inc. disclaims all warranties, express orimplied, and in particular, disclaims all warranties of merchantability,fitness for a particular purpose, and warranties related to the code, or anyservice or software related thereto.
NetSuite Inc. shall not be liablefor any direct, indirect or consequential damages or costs of any type arisingout of any action taken by you or others related to the sample code.