NopeCHALLC / nopecha-nodejs

Automated CAPTCHA solver for Node.js.
MIT License
957 stars 3 forks source link

500 Internal Server Error #4

Closed DemonMartin closed 5 months ago

DemonMartin commented 6 months ago

When using the NPM Module, I receive this error:

SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at JSON.parse (<anonymous>)
    at Response.json (file:///C:/Users/skubi/Desktop/Folder/Coding/MoneyPrinter/node_modules/node-fetch/src/body.js:149:15)   
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async NopeCHAApi.post (C:\Users\skubi\Desktop\Folder\Coding\MoneyPrinter\node_modules\nopecha\nopecha.js:193:24)       
    at async NopeCHAApi.solve (C:\Users\skubi\Desktop\Folder\Coding\MoneyPrinter\node_modules\nopecha\nopecha.js:202:17)      
    at async NopeCHAApi.solveToken (C:\Users\skubi\Desktop\Folder\Coding\MoneyPrinter\node_modules\nopecha\nopecha.js:220:16)

When I edited the nopecha.js to give me the body in text, it responds with this:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
[no address given] to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>

My code used:

 async solveHCaptchaNopecha(siteKey, url) {
        const configuration = new Configuration({
            apiKey: process.env.SOLVER_API_KEY
        });

        const nopecha = new NopeCHAApi(configuration);

        return await nopecha.solveToken({
            type: "hcaptcha",
            sitekey: siteKey,
            url: url
        })
    }
NopeCHALLC commented 6 months ago

We're aware of the server connectivity issues. Our service is experiencing spikes in traffic, and as a result, you may sometimes run into 5xx responses like you posted here. While we work on upgrading the infra to support increased load, we suggest catching these types of errors and retrying the request until you receive a 2xx response.

Edit: Code 500 for this issue was thrown due to reasons other than the previous comment.

DemonMartin commented 6 months ago

I retried 25 times... Additionally, I think the module should be updated to catch those errors and return a correct error instead of saying "Unexpected token '<', "<!DOCTYPE "... is not valid JSON" due to invalid parsing.

NopeCHALLC commented 5 months ago

The token endpoint cannot be accessed using a GitHub key. The server now returns a 403 if a GitHub key is used for an unavailable endpoint. The Node.js wrapper has updated to throw the correct error in commit c713762ace5c9f80257606fb6cd0bad0582e3b4f.