Business request process
The CAPTCHA request process involves the interaction between the business client (frontend), business server (backend), and Captcha server. The sequence diagram of calls is shown as follows:
To ensure that customers' business processes run normally in case of an exception in the Captcha server, we provide the following business disaster recovery schemes.
Note:
No billing is incurred when verifying any disaster recovery tickets generated in the disaster recovery schemes.
Business client (frontend) disaster recovery
1. Define the JS load error handling function.
function loadErrorCallback() {
var appid = 'CaptchaAppId';
var ticket = 'terror_1001_' + appid + '_' + Math.floor(new Date().getTime() / 1000);
callback({
ret: 0,
randstr: '@'+ Math.random().toString(36).substr(2),
ticket,
errorCode: 1001,
errorMessage: 'jsload_error',
});
}
2. Call the JS load error handling function if an error is caught during the CAPTCHA instance call.
try {
var captcha = new TencentCaptcha(document.getElementById('cap_iframe'), 'Your CAPTCHA's CaptchaAppId', callback, {});
captcha.show();
} catch (error) {
loadErrorCallback();
}
3. Define the CAPTCHA callback function so the handling is based on ticket and errorCode (instead of ret). For errorCode definitions, please see Web Frontend Integration. function callback(res) {
if (res.ticket){
if(res.errorCode === xxxxx){
}
}
}
Business server (backend) disaster recovery
In case of an exception when requesting the ticket verification API, the business server needs to handle the exception (for example, skip this verification) to avoid affecting business processes due to abnormal API responses, request timeouts, or the service not responding. The following are some abnormal responses that require disaster recovery on the business side.
Request timeout or service not responding.
Exception returned. Code is InternalError. Example:
{
"Response": {
"Error": {
"Code": "InternalError",
"Message": "An internal error has occurred. Retry your request. If the problem persists, contact us."
},
"RequestId": "xxxxxxxxxxx"
}
}
Service internal error. CaptchaCode is 26. Example:
{
"Response": {
"CaptchaCode": 26,
"CaptchaMsg": "System busy. For more information, please see the TenDI Captcha documentation. Search for the keyword "DescribeCaptchaResult", and check the description of the CaptchaCode field in the output parameters",
"EvilLevel": 0,
"GetCaptchaTime": 0,
"RequestId": "xxxxxxxxxxx"
},
"retcode": 0,
"retmsg": "ok"
}
You can log in to the Captcha console, and click Quick Consulting in the upper right corner to learn more.
Was this page helpful?