Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TooManyRequestsError #107

Open
luandro opened this issue Nov 3, 2022 · 13 comments
Open

TooManyRequestsError #107

luandro opened this issue Nov 3, 2022 · 13 comments

Comments

@luandro
Copy link

luandro commented Nov 3, 2022

You talk about this on the README, but I feel that before the re-write this didn't happen as often. Does it make any sense? And why am I hitting the limit so fast? Can't seem to get any proxies to work to circunvent the problem.

@vitalets
Copy link
Owner

vitalets commented Nov 3, 2022

You talk about this on the README, but I feel that before the re-write this didn't happen as often. Does it make any sense?

I think it's possible as we are using another route. Could you share some numbers? How many requests are you doing?

Concerning proxies - just checked 172.105.13.173 from the list, it worked. How do you try?

@luandro
Copy link
Author

luandro commented Nov 3, 2022

Don't have exact numbers sorry. But def not over 100, and not many per second. A colleague guessed this:

I think Google can basically put any limit they want onto that, and they probably have ways of detecting that it's not coming from a browser.

Regarding the proxy I tried dynamically fetching proxies... I'll have to try again with the one you shared.

@vitalets
Copy link
Owner

vitalets commented Nov 3, 2022

Could you try send requests with changing user-agent / other headers? It's simple trick but maybe it help..

For my own tasks I've created a simple service with node-http-proxy and pass it's host as parameter to translate. It makes sense to share it in readme I think.

@vitalets
Copy link
Owner

vitalets commented Nov 3, 2022

Regarding the proxy I tried dynamically fetching proxies...

Please check yes in Google column

@bora19
Copy link

bora19 commented Jan 5, 2023

@vitalets How would you track the number of requests? Is the rate limit by request or by characters? I was reading it was 6k characters but not sure or even how often. I'm also encountering the too many requests error, I have been testing only hence not a lot of requests but some test have been done on big strings. I was also not able to make the proxy work from the list after selecting only from the ones that say yes under Google column (roughly 111 distinct ones) with no luck. Perhaps a quick sample to get us going might help. I'm also wondering how long do those proxies lasts so I can update them accordingly. Thoughts/ideas?

@alexbash7
Copy link

Could you try send requests with changing user-agent / other headers? It's simple trick but maybe it help..

For my own tasks I've created a simple service with node-http-proxy and pass it's host as parameter to translate. It makes sense to share it in readme I think.

Can you please share code sample with modified user-agent header? Thank you

@vitalets
Copy link
Owner

vitalets commented Jan 14, 2023

@vitalets How would you track the number of requests? Is the rate limit by request or by characters? I was reading it was 6k characters but not sure or even how often. I'm also encountering the too many requests error, I have been testing only hence not a lot of requests but some test have been done on big strings. I was also not able to make the proxy work from the list after selecting only from the ones that say yes under Google column (roughly 111 distinct ones) with no luck. Perhaps a quick sample to get us going might help. I'm also wondering how long do those proxies lasts so I can update them accordingly. Thoughts/ideas?

I've made several examples. One is to run translate with proxy. Another is to count requests until you get TooManyRequests error. I guess limit is by number of requests not by total characters. It would be great if you share what you will get.

The most interesting thing for me is how much time should pass for Google to unblock particular IP address.

@vitalets
Copy link
Owner

Can you please share code sample with modified user-agent header? Thank you

Here it is
But in my tests it does not help with TooManyRequests error though.

@alexbash7
Copy link

I've tried datacenter rotational proxy that changes IP every request and mobile rotational proxy that change IP every few minutes, both keep returning 'Too Many Reuqest' error. Tried delay between 10ms and 1 sec, but nothing helped.

I used previous version v8.0.0 and it worked great with everything same proxy/delay, so probably something changed in v9.0 that trigger this error.

My guess this is no IP/delay related, since error persist with new IPs, seems like google detect my request based on other data like user-agent, etc

@vitalets
Copy link
Owner

vitalets commented Jan 15, 2023

I've tried datacenter rotational proxy that changes IP every request and mobile rotational proxy that change IP every few minutes, both keep returning 'Too Many Reuqest' error. Tried delay between 10ms and 1 sec, but nothing helped.

Hmm.. I've just made a test from my local machine. Run npx ts-node-esm examples/hit-too-many-reqs. After 400 reqs I've got TooManyRequestsError:

...
# 400: I have to learn German!
# 401: I have to learn German!
file:///Users/vitalets/projects/google-translate-api/src/index.ts:77
      return createHttpError(res.status, message);
             ^
TooManyRequestsError: Too Many Requests IP: 37.252.91.13, Time: 2023-01-15T09:13:17Z, Url: https://translate.google.com/translate_a/single?client=at&dt=t&dt=rm&dj=1

Now every request gets this error:

$ npx ts-node-esm examples/hit-too-many-reqs
Translating: Ich muss Deutsch lernen!
file:///Users/vitalets/projects/google-translate-api/src/index.ts:77
      return createHttpError(res.status, message);
             ^
TooManyRequestsError: Too Many Requests IP: 37.252.91.13, Time: 2023-01-15T09:15:34Z, Url: https://translate.google.com/translate_a/single?client=at&dt=t&dt=rm&dj=1

But if I use proxy, error disappears:

$ npx ts-node-esm examples/with-proxy 8.210.83.33:80
Using proxy: 8.210.83.33:80
Translating: Ich muss Deutsch lernen!
Result: I have to learn German!

It seems changing IP should help.
I've published new version 9.1.0 that shows IP in error message (as in my code above). Could you update to the latest version and re-check with datacenter rotational proxy? In case all requests come from different IPs you will see it in error messages.

I used previous version v8.0.0 and it worked great with everything same proxy/delay, so probably something changed in v9.0 that trigger this error.

Yes, version 8 used another google api url that may have different limits policy. But there is painful bug in v8 that's why library migrated to another url.

@taishi55
Copy link

taishi55 commented Feb 8, 2023

The agent seems not working.
const agent = createHttpProxyAgent('http://103.152.112.162:80');

Can you do something like this below?

const response = await fetch(url, {
	headers: {
		'User-Agent': randomUserAgent,
		'X-Forwarded-For': randomIpAddress
	}
});

@RadhixAwp
Copy link

RadhixAwp commented Feb 14, 2023

FetchError: request to https://translate.google.com/translate_a/single?client=at&dt=t&dt=rm&dj=1 failed, reason: connect ETIMEDOUT 117.54.114.102:80 at ClientRequest.<anonymous> (C:\Users\Radhi Sghaier\Downloads\test\node_modules\node-fetch\lib\index.js:1505:11) at ClientRequest.emit (node:events:513:28) at onerror (C:\Users\Radhi Sghaier\Downloads\test\node_modules\agent-base\dist\src\index.js:117:21) at callbackError (C:\Users\Radhi Sghaier\Downloads\test\node_modules\agent-base\dist\src\index.js:136:17) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { type: 'system', errno: 'ETIMEDOUT', code: 'ETIMEDOUT' }
}
and here i'am with a timedout lol

@AidanWelch
Copy link

It seems like its based on a lot of factors, but the single translate endpoint is the only endpoint that has this issue, batch_execute which a lot of projects use has no usage limits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants