{"record":{"id":"ca2351e4a8064716","repo":"alibaba/arthas","slug":"create-api-session-failed","errorCode":null,"errorMessage":"create api session failed","messagePattern":"create api session failed","errorType":"http","errorClass":"ApiException","httpStatus":200,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/shell/term/impl/http/api/HttpApiHandler.java","lineNumber":254,"sourceCode":"\n            //welcome message\n            WelcomeModel welcomeModel = new WelcomeModel();\n            welcomeModel.setVersion(ArthasBanner.version());\n            welcomeModel.setWiki(ArthasBanner.wiki());\n            welcomeModel.setTutorials(ArthasBanner.tutorials());\n            welcomeModel.setMainClass(PidUtils.mainClass());\n            welcomeModel.setPid(PidUtils.currentPid());\n            welcomeModel.setTime(DateUtils.getCurrentDateTime());\n            resultDistributor.appendResult(welcomeModel);\n\n            //allow input\n            updateSessionInputStatus(session, InputStatus.ALLOW_INPUT);\n\n            response.setSessionId(session.getSessionId())\n                    .setConsumerId(resultConsumer.getConsumerId())\n                    .setState(ApiState.SUCCEEDED);\n        } else {\n            throw new ApiException(\"create api session failed\");\n        }\n        return response;\n    }\n\n    /**\n     * Update session input status for all consumer\n     *\n     * @param session\n     * @param inputStatus\n     */\n    private void updateSessionInputStatus(Session session, InputStatus inputStatus) {\n        SharingResultDistributor resultDistributor = session.getResultDistributor();\n        if (resultDistributor != null) {\n            resultDistributor.appendResult(new InputStatusModel(inputStatus));\n        }\n    }\n\n    private ApiResponse processJoinSessionRequest(ApiRequest apiRequest, Session session) {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/shell/term/impl/http/api/HttpApiHandler.java#L236-L272","documentation":"Thrown during INIT_SESSION processing when sessionManager.createSession() returns null. A null session indicates the session manager refused to create a new session — typically because it is closed, at capacity, or in an error state. Without a session the API cannot proceed.","triggerScenarios":"The SessionManager is in a closed state (Arthas is shutting down), has hit a maximum session count limit, or an internal error prevented session creation.","commonSituations":"Arthas is in the middle of a shutdown/detach sequence. Too many concurrent sessions exhausting resources. Session manager initialization failed earlier.","solutions":["Retry INIT_SESSION after confirming Arthas is still running and healthy (check arthas.log).","Close unused sessions (CLOSE_SESSION) to free capacity if a session limit is the cause.","Restart Arthas if the session manager is in a bad state."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    response = initSession();\n} catch (ApiException e) {\n    if (e.getMessage().contains(\"create api session failed\")) {\n        // wait briefly and retry; if persistent, Arthas may be shutting down\n        Thread.sleep(2000);\n        response = initSession();\n    }\n}","preventionTips":["Close unused sessions to avoid exhausting session capacity.","Retry INIT_SESSION if it fails transiently.","Check arthas.log for session manager errors."],"tags":["http-api","session","init-session"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}