Coder Social home page Coder Social logo

All requests get - RuntimeError: Rate limit exceeded for sending requests to poe.com. Please try again later. about poe-api-wrapper HOT 39 CLOSED

bluusun avatar bluusun commented on June 3, 2024
All requests get - RuntimeError: Rate limit exceeded for sending requests to poe.com. Please try again later.

from poe-api-wrapper.

Comments (39)

snowby666 avatar snowby666 commented on June 3, 2024 6

Okay good news is I've figured out why the tokens only work on old accounts but not the new ones. Turns out poe api now requires a second token for making request. I'll update the patch soon with the uploading file fix as well

from poe-api-wrapper.

snowby666 avatar snowby666 commented on June 3, 2024 2

I've released the patch

from poe-api-wrapper.

snowby666 avatar snowby666 commented on June 3, 2024 1

Can you try with m-b cookie from quora? The wrapper sends requests to quora.com/poe_api/ so quora cookie is more recommended. Maybe they've removed the p-b cookie. Let me if I can troubleshoot this.

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024 1

After creating a Quora account for that email (was only poe.com before) it started to work again with either token.

from poe-api-wrapper.

snowby666 avatar snowby666 commented on June 3, 2024 1

Thanks for the info. I'll update the documentation specifying this problem with token later.

from poe-api-wrapper.

snowby666 avatar snowby666 commented on June 3, 2024 1

may the error was caused by Cloudflare's Firewall ?
I got error when connect_ws -> get_channel_settings -> send_request.
the result of send_request is 403. the following is response header.
...

Perhaps this could also explain why some people encounter errors while others don't; some people can resolve the issue by changing their IP address, but the error reappears after a while. The firewall initiates a human verification challenge after detecting a large number of anomalous requests.

I see. I think I will use a requests library that can bypass cloudflare.

I've tried making 60 requests (make a request every 1 second) and it runs normally now

from poe-api-wrapper.

snowby666 avatar snowby666 commented on June 3, 2024

Can you check your compute points balance in Settings section?

I've tested with virtual machine and it still works for me

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

iDB 2024-03-12 at 08 47 28
That was my first thought too but plenty left. What else can trigger that error (same user agent)?

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

I am using p-b value from poe.com (as before). Tried url decoded and not url decoded. Same result.

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

iDB 2024-03-12 at 08 54 23
Works in web interface...

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Is there a way to get verbose output for the connection?

def connect_ws(self, timeout=20):
if self.ws_connected:
return

    if self.ws_connecting:
        while not self.ws_connected:
            sleep(0.01)
        return

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Seems the issues is back now - seems there is a real new rate limiter at work (very aggressive). Do you have an example what proxy to use?

I have the impression the block is there for any IP that is connecting (so proxy may not work, switching IPs locally did not do anything).

The issue is the same using p-b or m-b token now. No issues using poe.com website.

To recreate the issue - make a request every 20 seconds (must be unique prompt or might be cached). Block happens after about 60-80 requests and lasts???

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Also odd (after blocking) I switched IP (and got RuntimeError: Rate limit exceeded for sending requests to poe.com. Please try again later.) and then created a new poe.com account and changed token (and kept IP). Same RuntimeError: Rate limit exceeded for sending requests to poe.com. Please try again later.!

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Maybe it is worth looking into the static useragent and other static elements for ws connection in api.py?

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

I used this to connect to the WS endpoint I got from my browser and had no trouble connecting and streaming messages) despite the 'blocked'. Note I did not specify a useragent or even cookie (browser already authenticated me earlier :)

websocat "wss://tch385627.tch.poe.com/up/chan67-8888/updates?min_seq=numbers&channel=poe-chanxx-yyyy-validsecret&hash=secret"
--header="Pragma: no-cache"
--header="Origin: https://poe.com"
--header="Accept-Language: en-US,en;q=0.9"
--header="Sec-WebSocket-Key: secret"

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Thanks for your help with this! Just sent some buymeacoffee :) Your Discord link seems broken...

from poe-api-wrapper.

nlpander avatar nlpander commented on June 3, 2024

Yep seeing the same issue here, verified that I have credits left with my account, getting the same message:
RuntimeError: Rate limit exceeded for sending requests to poe.com. Please try again later.

Could something have been altered with the graphql client or cookie requirements ?
'apollographql-client-version': '1.1.6-65'

from poe-api-wrapper.

xcrong avatar xcrong commented on June 3, 2024

may the error was caused by Cloudflare's Firewall ?

I got error when connect_ws -> get_channel_settings -> subscribe -> send_request.

the result of send_request is 403. the following is response header.

Headers({
   'date': 'Wed, 13 Mar 2024 02:01:04 GMT',
   'content-type': 'text/html; charset=UTF-8',
   'transfer-encoding': 'chunked',
   'connection': 'close',
   'accept-ch': 'Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA',
   'cross-origin-embedder-policy': 'require-corp',
   'cross-origin-opener-policy': 'same-origin',
   'cross-origin-resource-policy': 'same-origin',
   'origin-agent-cluster': '?1',
   'permissions-policy': 'accelerometer=(),autoplay=(),browsing-topics=(),camera=(),clipboard-read=(),clipboard-write=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=()',
   'referrer-policy': 'same-origin',
   'x-frame-options': 'SAMEORIGIN',
   'cf-mitigated': 'challenge',
   'cf-chl-out': 'bo2Mzka3wqWOCHwN4s96a3/XnMLSILZGMkjTrhDBd8roBn8kDbAr4M0PEmW4HVTuIQlk56B54MBjzIde58zLmT7Tuy1Hd/zEa8ZaIEHA09wU6yXeOV5Um/55xP452GRzaI4XLx6sdosGLBuAhKSphw==$wrJJG5dkDGoe+6Wvjk5xjw==',
   'cache-control': 'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
   'expires': 'Thu, 01 Jan 1970 00:00:01 GMT',
   'vary': 'Accept-Encoding',
   'server': 'cloudflare',
   'cf-ray': '86386f1dd96636d8-YYZ',
   'content-encoding': 'gzip',
   'alt-svc': 'h3=":443"; ma=86400'
})

Claude 3 (sonnet) say:

Based on the response headers you provided, the 403 error you received is caused by the Cloudflare Web Application Firewall (WAF).

The cf-mitigated: challenge header indicates that Cloudflare detected your request as potentially non-human or malicious, and therefore sent a challenge to validate whether you are a legitimate human user.

Additionally, the cf-chl-out header contains an encrypted data, which may include instructions needed for the validation.

To resolve this issue, you have the following options:

  1. Try resending the request
    Sometimes Cloudflare temporarily blocks certain requests, and resending may succeed.

  2. Solve the Cloudflare challenge
    Follow the instructions in the cf-chl-out header to solve the challenge provided by Cloudflare, proving that you are a legitimate human user. This usually involves parsing a JavaScript challenge or completing a captcha.

  3. Check and optimize client behavior
    Review your request patterns for any anomalies, such as sending too many requests, requests with short intervals, etc., and optimize accordingly.

  4. Contact the website owner
    If the above methods fail, you can try contacting the website owner and request that your client IP or user agent be whitelisted to avoid triggering Cloudflare's WAF rules.

In general, since Cloudflare's WAF rules are designed to prevent malicious behavior and attacks, reasonably optimizing client request patterns and solving the validation challenges are effective ways to bypass the 403 error.

from poe-api-wrapper.

xcrong avatar xcrong commented on June 3, 2024

may the error was caused by Cloudflare's Firewall ?

I got error when connect_ws -> get_channel_settings -> send_request.

the result of send_request is 403. the following is response header.

...

Perhaps this could also explain why some people encounter errors while others don't; some people can resolve the issue by changing their IP address, but the error reappears after a while. The firewall initiates a human verification challenge after detecting a large number of anomalous requests.

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Maybe adding the cf token will solve it - this usually makes cf accept requests without further issues.

from poe-api-wrapper.

snowby666 avatar snowby666 commented on June 3, 2024

Can someone help me test again if the rate limiter still works?

from poe-api-wrapper.

xcrong avatar xcrong commented on June 3, 2024

Can someone help me test again if the rate limiter still works?

I tried again, and now the response code is 200, but the data in the response body indicates an error, and I still can't establish a WebSocket connection. My cookie was just copied from the browser, and I tried both poe and quora's cookies.

200
{'data': None, 'errors': [{'message': 'Server Error'}], 'extensions': {'is_final': True}}

I remember that when I got this kind of error before, I could fix it by updating the queryHash in the subscribe function; but this time, even after I tried updating it, it still returns the same error. I added two print statements in the send_request function.

def send_request(...):
    ...

    print(response.status_code)
    # print(response.text)
    # print(response.headers)

    if response.status_code == 200:
        for file in file_form:
            if hasattr(file[1], "closed") and not file[1].closed:
                file[1].close()
        print(response.json())
        return response.json()
    else:
        raise RuntimeError(
            f"An unknown error occurred. Raw response data: {response.text}"
        )

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Downloaded newest version from pip. No changes (same error) for my tokens. Noticed that the account I created yesterday works now (free account) but not any of the other accounts (Premium). Other Free accounts are still blocked. Is there a way I can reach you to provide tokens for you to test?

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

My response is:

RuntimeError: Failed to subscribe by sending SubscriptionsMutation. Raw response data: {'data': None, 'errors': [{'message': 'Server Error'}], 'extensions': {'is_final': True}}

DEBUG:root:Response content: {"data": null, "errors": [{"message": "Server Error"}], "extensions": {"is_final": true}}

When I use a a simple curl using my tokens I get proper data back:

curl 'https://www.quora.com/poe_api/settings'
-H 'authority: www.quora.com'
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7'
-H 'accept-language: en-US,en;q=0.9'
-H 'cache-control: no-cache'
-H 'cookie: m-b=token'
-H 'pragma: no-cache'
-H 'sec-ch-ua: "Not A(Brand";v="99", "Opera";v="107", "Chromium";v="121"'
-H 'sec-ch-ua-mobile: ?0'
-H 'sec-ch-ua-platform: "macOS"'
-H 'sec-fetch-dest: document'
-H 'sec-fetch-mode: navigate'
-H 'sec-fetch-site: none'
-H 'sec-fetch-user: ?1'
-H 'upgrade-insecure-requests: 1'
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0.0'
--compressed

-->

{"formkey": "formkey", "tchannelData": {"minSeq": "7475948979", "channel": "mychannel", "channelHash": "hash", "boxName": "chan57-8888", "baseHost": "poe.com", "targetUrl": "", "enableWebsocket": true}}%

from poe-api-wrapper.

XenocodeRCE avatar XenocodeRCE commented on June 3, 2024

A temporary fix for me (I hope it will be fixed, but I suspect Quora/Poe dev to lurk into this repo very often) is to use a mix of python and AutoHotKey script on a Windows VPS using the Poe windows app.

I send the prompt to local php on the VPS, then it open Poe app, click on the desired bot, paste the prompt, then I wait till response is done and I grab the content, copy and send back the response to the PHP ...

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

It appears to me that the data provided by the endpoint https://www.quora.com/poe_api/settings does not provide a proper ws channel connection (anymore). I can run the request successfully using m-b token but the data provided does not provide a ws connection anymore (at least I seem to get no data from it). Specifically it seems the minSeq counter is (far) off by many hundreds of thousands.

However when I tried this endpoint https://poe.com/api/settings?channel=poe-chan.... I was able to get correct minSequence information and was able to establish a valid WS connection (note it seemed empty initially but started working after my first bot request).

I am not sure if channel is required for the request:

curl 'https://poe.com/api/settings?channel=poe-chan59-8888-secret'
-H 'authority: poe.com'
-H 'accept: /'
-H 'accept-language: en-US,en;q=0.9'
-H 'cache-control: no-cache'
-H 'cookie: p-b=token'
-H 'pragma: no-cache'
-H 'referer: https://poe.com/settings'
-H 'sec-ch-ua: "Not A(Brand";v="99", "Opera";v="107", "Chromium";v="121"'
-H 'sec-ch-ua-mobile: ?0'
-H 'sec-ch-ua-platform: "macOS"'
-H 'sec-fetch-dest: empty'
-H 'sec-fetch-mode: cors'
-H 'sec-fetch-site: same-origin'
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0.0'
--compressed

Returns (removed values):

{"tchannelData":{"minSeq":"8887813834","channel":"","channelHash":"","boxName":"","baseHost":"poe.com","targetUrl":"","enableWebsocket":true}}%

It seems minSeq is a global counter but it might be random.

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Could you make the changes and check if that fixes it?

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

BTW there is a long standing bug that every 20th request or so gets mismatched (i.e. bot reply is sent to wrong request ID), little annoying and likely easy to fix by strict check for message id?

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Turns out the parameter for the settings endpoint is now required to get the right minSeq .... /settings?channel=poe-chan59-8888-secret . I am not sure how it can be obtained (or it may be static per account (like the cookie?).

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Did it just come back?

from poe-api-wrapper.

nlpander avatar nlpander commented on June 3, 2024

No not for me, still not able to access the wrapper - tried both p-b and m-b tokens switched IPs as well.

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Been issuing new tokens several times and it came back. However I can't use file as attachments anymore :(

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Awesome! For accounts that don't have the new extra token will the API be backward compatible?

from poe-api-wrapper.

snowby666 avatar snowby666 commented on June 3, 2024

Awesome! For accounts that don't have the new extra token will the API be backward compatible?

In that case, you can try deleting cookies and login again then there should be 2 tokens

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Rate limit exceeded is back for 1.3.9 AND 1.4.0 :( Using 2 tokens - this worked for a few days!

from poe-api-wrapper.

palislau avatar palislau commented on June 3, 2024

Rate limit exceeded is back for 1.3.9 AND 1.4.0 :( Using 2 tokens - this worked for a few days!

same for me

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

I see this in newest version a lot:

2024-03-28 20:32:28.457 | DEBUG | poe_api_wrapper.api:connect_ws:164 - An unknown error occurred. Raw response data: <title>Just a moment...</title><style>*{box-sizing:border-box;margin:0;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%;color:#313131}button,html{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}@media (prefers-color-scheme:dark){body{background-color:#222;color:#d9d9d9}body a{color:#fff}body a:hover{color:#ee730a;text-decoration:underline}body .lds-ring div{border-color:#999 transparent transparent}body .font-red{color:#b20f03}body .big-button,body .pow-button{background-color:#4693ff;color:#1d1d1d}body #challenge-success-text{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgZmlsbD0ibm9uZSIgdmlld0JveD0iMCAwIDI2IDI2Ij48cGF0aCBmaWxsPSIjZDlkOWQ5IiBkPSJNMTMgMGExMyAxMyAwIDEgMCAwIDI2IDEzIDEzIDAgMCAwIDAtMjZtMCAyNGExMSAxMSAwIDEgMSAwLTIyIDExIDExIDAgMCAxIDAgMjIiLz48cGF0aCBmaWxsPSIjZDlkOWQ5IiBkPSJtMTAuOTU1IDE2LjA1NS0zLjk1LTQuMTI1LTEuNDQ1IDEuMzg1IDUuMzcgNS42MSA5LjQ5NS05LjYtMS40Mi0xLjQwNXoiLz48L3N2Zz4=)}body #challenge-error-text{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0IyMEYwMyIgZD0iTTE2IDNhMTMgMTMgMCAxIDAgMTMgMTNBMTMuMDE1IDEzLjAxNSAwIDAgMCAxNiAzbTAgMjRhMTEgMTEgMCAxIDEgMTEtMTEgMTEuMDEgMTEuMDEgMCAwIDEtMTEgMTEiLz48cGF0aCBmaWxsPSIjQjIwRjAzIiBkPSJNMTcuMDM4IDE4LjYxNUgxNC44N0wxNC41NjMgOS41aDIuNzgzem0tMS4wODQgMS40MjdxLjY2IDAgMS4wNTcuMzg4LjQwNy4zODkuNDA3Ljk

....

po.src = '/cdn-cgi/challenge-platform/h/g/orchestrate/chl_page/v1?ray=86bccafe1b030824';window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, location.href.length - window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;if (window.history && window.history.replaceState) {var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;history.replaceState(null, null, "/poe_api/gql_POST?__cf_chl_rt_tk=YdCkvhDLOMYtcN89xy1ZZObKl80wOsWzhOKkDCUpL04-1711683148-0.0.1.1-1599" + window._cf_chl_opt.cOgUHash);cpo.onload = function() {history.replaceState(null, null, ogU);}}document.getElementsByTagName('head')[0].appendChild(cpo);}());</script>

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

Makes it seem like the CF cookie should be included.

from poe-api-wrapper.

bluusun avatar bluusun commented on June 3, 2024

iDB 2024-03-28 at 20 47 04
I can't find the m-lat token in quora - what am I missing? # Using quora.com tokens
tokens = {
'b': 'm-b token here',
'lat': 'm-lat token here'
}

from poe-api-wrapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.