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

HTTPError 302 after regular translation #12

Closed
kalpak44 opened this issue Aug 14, 2019 · 8 comments
Closed

HTTPError 302 after regular translation #12

kalpak44 opened this issue Aug 14, 2019 · 8 comments

Comments

@kalpak44
Copy link

kalpak44 commented Aug 14, 2019

After a few successful translates start to fail with warnings:
node index.js { HTTPError at translate (C:\Users\User\Desktop\node_test\node_modules\@k3rn31p4nic\google-translate-api\src\index.js:143:19) at process._tickCallback (internal/process/next_tick.js:68:7) name: 'HTTPError', statusCode: 302, statusMessage: 'Found' }

index.js:

translate(articleRU, { from: 'ru', to: 'bg' }).then(res => { console.log(res.text); }).catch(err => { console.error(err); });

@iamtraction
Copy link
Owner

Are you still getting the error?

@cheesits456
Copy link

I ran into the same issue while using this for a live translator that I implemented into my Discord bot
image

@iamtraction
Copy link
Owner

Can you give a minimal reproducible example?

@kalpak44
Copy link
Author

kalpak44 commented Feb 28, 2020

I did not watch the implementation, but the requests themselves towards Google translator are banned with frequent use. The first several times is ok, after several times start to throw different errors or res.text is empty string

In case like this

function index(){
	var things = ['Rock', 'Paper', 'Scissor', 'Apple', 'Appearance', 'Announce'];
	var thing = things[Math.floor(Math.random()*things.length)];
	console.log("original: " + thing)
	translate(thing, { from: 'en', to: 'bg' }).then(res => {
		  console.log("translated: " + res.text)
		}).catch(err => {
		  console.error(err);
	});
	setTimeout(index, 5000);
}

index()

there throws something like:

{ HTTPError
    at translate (C:\Users\User\Desktop\node_test\node_modules\@k3rn31p4nic\google-translate-api\src\index.js:143:8)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'HTTPError',
  statusCode: 429,
  statusMessage: 'Too Many Requests' }

If text is longer then error is another:

{ HTTPError
    at translate (C:\Users\User\Desktop\node_test\node_modules\@k3rn31p4nic\google-translate-api\src\index.js:143:8)
    at process._tickCallback (internal/process/next_tick.js:68:7) name: 'HTTPError', statusCode: 302, statusMessage: 'Found' }

Do you know how often you can make requests without errors?

@cheesits456
Copy link

Hmm I've been looking into this problem and it seems to be pretty common - from what I've gathered so far, it seems the only way to get around the errors is either to slow down your requests, or use proxies so you don't get ratelimmited by Google

@iamtraction
Copy link
Owner

Do you know how often you can make requests without errors?

Nope. As this isn't an official API, we don't know about their rate limits.

@iamtraction
Copy link
Owner

If text is longer then error is another

How long of a text are you trying to send?

@iamtraction
Copy link
Owner

Closing it as it has become stale. Feel free to reopen if you're still facing the issue and have reproduction steps.

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

3 participants