{"record":{"id":"177a67d5178a6461","repo":"alibaba/canal","slug":"requestget-remote-error-url-code-error-ms","errorCode":null,"errorMessage":"requestGet remote error, url={}, code={}, error msg={}","messagePattern":"requestGet remote error, url=(.+?), code=(.+?), error msg=(.+?)","errorType":"http","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/plain/HttpHelper.java","lineNumber":96,"sourceCode":"                .setConnectionRequestTimeout(timeout)\n                .setSocketTimeout(timeout)\n                .build();\n            httpGet = new HttpGet(uri);\n            if (heads != null) {\n                for (Map.Entry<String, String> entry : heads.entrySet()) {\n                    httpGet.setHeader(entry.getKey(), entry.getValue());\n                }\n            }\n\n            HttpClientContext context = HttpClientContext.create();\n            context.setRequestConfig(config);\n            response = httpclient.execute(httpGet, context);\n            int statusCode = response.getStatusLine().getStatusCode();\n            if (statusCode == HttpStatus.SC_OK) {\n                return EntityUtils.toString(response.getEntity());\n            } else {\n                String errorMsg = EntityUtils.toString(response.getEntity());\n                throw new RuntimeException(\"requestGet remote error, url=\" + uri.toString() + \", code=\" + statusCode\n                                           + \", error msg=\" + errorMsg);\n            }\n        } catch (Throwable t) {\n            throw new RuntimeException(\"requestGet remote error, request : \" + url, t);\n        } finally {\n            if (response != null) {\n                try {\n                    response.close();\n                } catch (IOException e) {\n                    // ignore\n                }\n            }\n            if (httpGet != null) {\n                httpGet.releaseConnection();\n            }\n        }\n    }\n","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/plain/HttpHelper.java#L78-L114","documentation":"Inner throw in HttpHelper.get() (HttpHelper.java:96-97): fired when the HTTP response status is not 200 OK. Builds a RuntimeException with 'requestGet remote error, url=<uri>, code=<statusCode>, error msg=<response body>'. IMPORTANT: this exception is thrown inside the try block whose catch(Throwable t) at line 99-100 immediately re-wraps it as a NEW RuntimeException ('requestGet remote error, request : <url>', originalException-as-cause). So callers never directly catch the line-96 message — it survives only as the cause of the outer exception (error 357).","triggerScenarios":"HttpHelper.get(url, heads, timeout) returns a non-200 status from the canal-manager (or whatever remote it queries). The response body is consumed as the error message, then the RuntimeException is thrown and re-wrapped by the outer catch.","commonSituations":"Manager auth token expired/invalid (canal-manager returns 401/50014); manager endpoint moved or load-balanced to a wrong backend returning 404; manager returns 500 due to its own DB error; rate limiting (429); SSL termination returning an error page; wrong REST path producing 404.","solutions":["Read the nested cause (getCause()) of the RuntimeException thrown to the caller — it carries the original url/code/body message from line 96.","Address the underlying HTTP status: 401/50014 → refresh/reissue the manager token; 404 → verify the manager base URL and REST path; 500 → inspect manager server logs; 429 → back off / raise manager rate limits.","Confirm network reachability and that the manager is up: curl -i <url> with the same headers from the canal host.","If using HTTPS, validate the certificate chain (the client trusts all certs via NoopHostnameVerifier, so TLS errors here are usually endpoint/protocol issues, not trust)."],"exampleFix":"// before — message lost because outer catch re-wraps\ntry {\n    helper.get(url, heads, timeout);\n} catch (RuntimeException e) {\n    log.error(e.getMessage()); // only sees 'requestGet remote error, request : <url>'\n}\n\n// after — unwrap the cause to recover the status code and body\ntry {\n    helper.get(url, heads, timeout);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    if (cause != null && cause.getMessage() != null\n        && cause.getMessage().contains(\"code=\")) {\n        log.error(\"manager call failed: {}\", cause.getMessage());\n    } else {\n        log.error(\"manager call failed\", e);\n    }\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight: hit a cheap manager endpoint with the same headers to catch auth/404 early\ntry {\n    int code = simpleHead(url, heads, timeout);\n    if (code != 200) {\n        throw new IllegalStateException(\"manager pre-check failed: HTTP \" + code + \" for \" + url);\n    }\n} catch (IOException e) {\n    throw new IllegalStateException(\"manager unreachable: \" + url, e);\n}","typeGuard":null,"tryCatchPattern":"// HttpHelper re-wraps the inner throw; unwrap getCause() to recover status code + body\ntry {\n    String body = helper.get(url, heads, timeout);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    if (cause != null && cause.getMessage() != null && cause.getMessage().contains(\"code=\")) {\n        log.error(\"manager GET non-200: {}\", cause.getMessage());\n    } else {\n        log.error(\"manager GET failed\", e);\n    }\n    throw e;\n}","preventionTips":["Always unwrap getCause() — the line-96 message (url/code/body) is hidden inside the outer RuntimeException.","Refresh manager auth tokens before they expire to avoid 401/50014.","Pre-flight a cheap manager endpoint at startup to fail fast on auth/404.","Reproduce failing calls with curl -i using the same URL and headers."],"tags":["http","manager-client","rest","runtime-exception","error-wrapping"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}