alibaba/canal · error · RuntimeException

requestPost remote error, request : {}

Error message

requestPost remote error, request : {}

What it means

Thrown by the catch (Throwable t) block in HttpHelper.post() as an outer wrapper for ANY exception during the plain HTTP POST. Includes a curl-equivalent request string with cookies and params. The original exception is preserved as the cause.

Source

Thrown at parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/HttpHelper.java:308

            response = httpclient.execute(httpPost, context);
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == HttpStatus.SC_OK) {
                long end = System.currentTimeMillis();
                long cost = end - start;
                printCurlRequest(url, cookieStore, params, cost);
                return EntityUtils.toString(response.getEntity());
            } else {
                long end = System.currentTimeMillis();
                long cost = end - start;
                String curlRequest = getCurlRequest(url, cookieStore, params, cost);
                throw new RuntimeException("requestPost remote error, request : " + curlRequest + ", statusCode="
                                           + statusCode + ";" + EntityUtils.toString(response.getEntity()));
            }
        } catch (Throwable t) {
            long end = System.currentTimeMillis();
            long cost = end - start;
            String curlRequest = getCurlRequest(url, cookieStore, params, cost);
            throw new RuntimeException("requestPost remote error, request : " + curlRequest, t);
        } finally {
            if (response != null) {
                try {
                    response.close();
                } catch (IOException e) {
                }
            }
            if (httpPost != null) {
                httpPost.releaseConnection();
            }
        }
    }

    public static void printCurlRequest(String url, CookieStore cookieStore, Map<String, String> params, long cost) {
        logger.warn(getCurlRequest(url, cookieStore, params, cost));
    }

    private static String getCurlRequest(String url, CookieStore cookieStore, Map<String, String> params, long cost) {

View on GitHub (pinned to 87be50e876)

Solutions

  1. Check the cause exception for the real root cause.
  2. If cause is NullPointerException, ensure params is non-null before calling post().
  3. If cause is ConnectException, verify the target host and port are reachable.
  4. If cause is the inner RuntimeException (error 426), follow error 426 solutions.

Example fix

// before
HttpHelper.post(url, cookieStore, null, timeout);

// after
Map<String, String> params = new HashMap<>(); // ensure non-null
HttpHelper.post(url, cookieStore, params, timeout);
Defensive patterns

Strategy: validation

Validate before calling

// Validate params is non-null before calling post
if (params == null) {
    params = new java.util.HashMap<>();
}
if (url == null || url.trim().isEmpty()) {
    throw new IllegalArgumentException("URL must not be null or empty");
}

Try / catch

try {
    String result = HttpHelper.post(url, cookieStore, params, timeout);
} catch (RuntimeException e) {
    Throwable cause = e.getCause();
    if (cause instanceof NullPointerException) {
        // likely params or cookieStore was null
    } else if (cause instanceof java.net.ConnectException) {
        // endpoint unreachable
    }
}

Prevention

When it happens

Trigger: Any Throwable during HttpHelper.post(): the inner non-200 throw (error 426), ConnectException, SocketTimeoutException, IOException from entity writing, or NullPointerException if params map is null when iterating keys.

Common situations: Connection refused by the target service; socket timeout during slow POST response; params map is null causing NPE in the for loop at line 281; CookieStore.getCookies() throwing when cookieStore is null but params are non-null.

Related errors


AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14). Data as JSON: /api/errors/b5084558f4f1ac2f. Report an issue: GitHub.