Skip to main content

Android Error Code Description and Handling

When integrating the Android SDK, errors fall into two categories: client-side errors and server-side errors. Handle each error type separately. All errors trigger the onErrorReceived callback.

Client-side Errors

These errors typically stem from network issues. Common errors include the following:
TYError(key=0, message={"header":{"local_task_id":"ba29ac78ddbd42a7b7e8cfb7f0765461","name":"TaskFailed","status":51,"status_text":""}})
TYError(key=0, message={"header":{"local_task_id":"ca9682dc849742c0a1480712d0d8d9cc","name":"TaskFailed","status":315,"status_text":" GetInetAddressByHostname timeout host=dashscope.aliyuncs.com timeout=5000 host=dashscope.aliyuncs.com port=443 ip= sockfd=121"}})
TYError(key=0, message={"header":{"local_task_id":"951786d3b94141969374402653cc4412","name":"TaskFailed","status":301,"status_text":" Got bad status host=poc-dashscope.aliyuncs.com line=HTTP/1.1 401 Unauthorized\r\n token=123"}})
These are client-side errors. Restart the conversation.

Server-side Errors

For a list of error codes, see Multimodal Interaction Suite - Error Codes. These errors commonly result from server-side faults or client-side calls that trigger server-side errors. Common errors include the following:
TYError(key=0, message={"header":{"attributes":{},"error_code":"InternalAsrError","error_message":"Internal asr error","event":"task-failed","local_task_id":"454dcf408a334d1caa2c839dfa10a1f5","task_id":"6a0d507a5b494790a309d4ec68c91ae5"},"payload":{}})

TYError(key=0, message={"header":{"attributes":{},"event":"result-generated","local_task_id":"cc51a165b06841f48884b4915f7c7a29","task_id":"0b0a901e931b437cb2a8cda1aabe8ba4"},"payload":{"output":{"dialog_id":"82b86095-0eb8-4054-83a6-0666b3773f97","error_code":500,"error_message":"SOCKET_TIMEOUT_EXCEPTION: Read timed out","error_name":"InternalLLMError","event":"Error","llm_request_id":"6a56caf7d51349b79316e23303ab55ee","round_id":"0b1a4cd88b4b48b49c311a8c69f9d921"}}})

TYError(key=0, message={"header":{"attributes":{},"error_code":"TooManyInterrupt","error_message":"Send too many RequestToRespond or RequestToSpeak directives in a short time!","event":"task-failed","local_task_id":"bb33ae5b96f74a6986cc546e5003311e","task_id":"cef8f005d9494ab190911adf5b21aee1"},"payload":{}}})
Server-side errors fall into two types:
  1. The error message appears in the header. This is an unrecoverable error. Restart the conversation.
  2. The error message appears in the payload. This is a recoverable error. The conversation automatically returns to the Listening state, and execution can continue.

Error Handling

public void onErrorReceived(@NonNull TYError errorInfo) {
            Log.e(TAG, "Error received: " + errorInfo);
            com.alibaba.fastjson.JSONObject errorJson = (com.alibaba.fastjson.JSONObject) JSON.parse(errorInfo.getMessage());
            com.alibaba.fastjson.JSONObject header = null;
            com.alibaba.fastjson.JSONObject payload = null;
            boolean needRestart = false;
            if (errorJson != null && errorJson.containsKey("header")) {
                header = errorJson.getJSONObject("header");
                if (header != null && header.containsKey("name") && header.getString("name").equals("TaskFailed")) {
                // Client-side error, reconnect.
                    String errorCode = header.getString("status");
                    String errorMsg = header.getString("status_text");
                    needRestart = true;
                }
                if (header != null && header.containsKey("event") && header.getString("event").equals("task-failed")) {
                    // Server-side error, unrecoverable, reconnect.
                    String errorCode = header.getString("error_code");
                    String errorMsg = header.getString("error_message");
                    needRestart = true;
                }
            }
            if (errorJson != null && errorJson.containsKey("payload")) {
                payload = errorJson.getJSONObject("payload");
                if (payload != null && payload.containsKey("output") ) {
                    // Server-side error, message in payload, recoverable.
                    com.alibaba.fastjson.JSONObject output = payload.getJSONObject("output");
                    if (output != null && output.containsKey("event") && output.getString("event").equals("Error")) {
                        String errorCode = output.getString("error_code");
                        String errorMsg = output.getString("error_message");
                        needRestart = false;
                    }
                }
            }
            printErrorMessage(errorCode, errorMsg); // Print error message.
            if (needRestart) {
                restartConversation(); // Restart conversation.
            }
        }
Agent Development
Agent Context
Agent Governance & Evolution
Store
Application Marketplace