{"record":{"id":"389e3415545e83c0","repo":"Anankke/SSPanel-UIM","slug":"curl-error-curl","errorCode":null,"errorMessage":"curl_error($curl)","messagePattern":"curl_error\\(\\$curl\\)","errorType":"exception","errorClass":"App\\Services\\Gateway\\Cryptomus\\RequestBuilderException","httpStatus":null,"severity":"error","filePath":"src/Services/Gateway/Cryptomus/RequestBuilder.php","lineNumber":57,"sourceCode":"            'sign: ' . md5(base64_encode($body) . $this->secretKey),\n        ];\n\n        curl_setopt_array(\n            $curl,\n            [\n                CURLOPT_URL => $url,\n                CURLOPT_HTTPHEADER => $headers,\n                CURLOPT_POST => 1,\n                CURLOPT_POSTFIELDS => $body,\n                CURLOPT_RETURNTRANSFER => 1,\n            ],\n        );\n\n        $response = curl_exec($curl);\n        $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);\n\n        if ($response === false) {\n            throw new RequestBuilderException(curl_error($curl), $responseCode, $uri);\n        }\n\n        if ($response !== '') {\n            $json = json_decode($response, true);\n            if ($json === null) {\n                throw new RequestBuilderException(json_last_error_msg(), $responseCode, $uri);\n            }\n\n            if ($responseCode !== 200 || ($json['state'] !== null && $json['state'] !== 0)) {\n                if (isset($json['message']) && $json['message'] !== '') {\n                    throw new RequestBuilderException($json['message'], $responseCode, $uri);\n                }\n\n                if (isset($json['errors']) && $json['errors'] !== []) {\n                    throw new RequestBuilderException('Validation error', $responseCode, $uri, $json['errors']);\n                }\n            }\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/Anankke/SSPanel-UIM/blob/d55a607191cfc51cdbc836fba85196ddef4df343/src/Services/Gateway/Cryptomus/RequestBuilder.php#L39-L75","documentation":"This exception is thrown when the cURL call to the Cryptomus API fails at the transport level: curl_exec() returned false, so no HTTP response was ever received. The exception message is the raw libcurl error string (e.g. \"Could not resolve host: api.cryptomus.com\", \"Connection timed out\", \"SSL certificate problem\") and the code is curl_getinfo(CURLINFO_HTTP_CODE), which is 0 because the request never completed. Note that RequestBuilder sets no CURLOPT_CONNECTTIMEOUT/CURLOPT_TIMEOUT, so a hung connection only ends when PHP's max_execution_time aborts the script.","triggerScenarios":"sendRequest() POSTing to https://api.cryptomus.com/<uri> when: DNS for api.cryptomus.com cannot be resolved; the host or an intermediate firewall drops the TCP connection (timed out / connection refused); TLS negotiation fails (missing/outdated CA bundle on old PHP/cURL builds, e.g. \"SSL certificate problem: unable to get local issuer certificate\"); the server runs in an environment with no outbound internet (local dev, CI container, restricted production egress); a misconfigured HTTPS proxy env var (http_proxy/HTTPS_PROXY) makes curl dial the wrong host.","commonSituations":"Panel deployed on a VPS/hosting box with blocked outbound traffic to crypto-related domains; localhost/CI testing without network access; PHP 7.x with an outdated cacert.pem (CRYPTOMus requires TLS to api.cryptomus.com); IPv6-preferring hosts where AAAA lookup fails; corporate proxy not configured into curl.","solutions":["From the same host, run: curl -v https://api.cryptomus.com/payment-services to confirm whether the failure is DNS, TCP, or TLS — the exception message mirrors this output.","If the error mentions SSL certificates, set curl.cainfo / openssl.cafile in php.ini to an up-to-date cacert.pem (https://curl.se/ca/).","Ensure the environment allows outbound HTTPS to api.cryptomus.com (firewall/egress rules, DNS resolver working, proxy env vars correct or unset if unused).","Add CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT to the curl_setopt_array call so network hangs fail fast instead of burning max_execution_time.","Retry with backoff on exception code 0 — transport failures are frequently transient."],"exampleFix":"// before\ncurl_setopt_array($curl, [\n    CURLOPT_URL => $url,\n    CURLOPT_HTTPHEADER => $headers,\n    CURLOPT_POST => 1,\n    CURLOPT_POSTFIELDS => $body,\n    CURLOPT_RETURNTRANSFER => 1,\n]);\n\n// after\ncurl_setopt_array($curl, [\n    CURLOPT_URL => $url,\n    CURLOPT_HTTPHEADER => $headers,\n    CURLOPT_POST => 1,\n    CURLOPT_POSTFIELDS => $body,\n    CURLOPT_RETURNTRANSFER => 1,\n    CURLOPT_CONNECTTIMEOUT => 5,\n    CURLOPT_TIMEOUT => 30,\n]);\n// caller:\ntry {\n    $rb->sendRequest('v1/payment', $data);\n} catch (RequestBuilderException $e) {\n    if ($e->getCode() === 0) { /* transport failure: retry with backoff */ }\n}","handlingStrategy":"retry","validationCode":"// Before constructing RequestBuilder, fail fast on obviously bad config\n$secretKey = trim((string) config('cryptomus_key'));\n$merchantUuid = trim((string) config('cryptomus_uuid'));\nif ($secretKey === '' || $merchantUuid === '') {\n    throw new InvalidArgumentException('Cryptomus secret key / merchant UUID not configured');\n}\n// Optional cheap connectivity probe (skips the full payment call)\nif (gethostbyname('api.cryptomus.com') === 'api.cryptomus.com') {\n    throw new RuntimeException('Cannot resolve api.cryptomus.com — check DNS/egress');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $result = $rb->sendRequest('v1/payment', $data);\n} catch (App\\Services\\Gateway\\Cryptomus\\RequestBuilderException $e) {\n    if ($e->getCode() === 0) {\n        // transport-level curl failure ($e->getMessage() is the curl_error string)\n        // safe to retry with exponential backoff: 1s, 2s, 4s\n        return retryWithBackoff(fn () => $rb->sendRequest('v1/payment', $data), 3);\n    }\n    throw $e; // real API response — do not blind-retry\n}","preventionTips":["Set CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT in the builder so hung sockets fail fast instead of stalling the request.","Monitor exception code 0 separately from HTTP codes — it identifies network problems you can alert or retry on.","Keep the PHP CA bundle current (curl.cainfo pointing at an up-to-date cacert.pem) on all deployment hosts.","Verify outbound HTTPS to api.cryptomus.com is allowed when provisioning new servers/containers."],"tags":["php","curl","cryptomus","network","transport","dns","tls"],"backgroundTag":"curl-request-failed","analyzedSha":"d55a607191cfc51cdbc836fba85196ddef4df343","analyzedAt":"2026-08-21T04:59:05.849Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}