google-translate-api
google-translate-api copied to clipboard
BAD_REQUEST response
When our app faced with BAD_REQUEST, it won't be back to normal.
2018-06-04T12:55:26.318090+00:00 app[schedule.1]: { Error
2018-06-04T12:55:26.318105+00:00 app[schedule.1]: at /app/node_modules/google-translate-api/index.js:105:17
2018-06-04T12:55:26.318106+00:00 app[schedule.1]: at process._tickCallback (internal/process/next_tick.js:109:7) code: 'BAD_REQUEST' }
Do we have limit on number of requests per second? Our app was working fine till it face with above error.
Yeah I've recently been getting this issue as well
Yeah I've recently been getting this issue as well
node_modules/google-translate-api/index.js:105:17 at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7) code: 'BAD_REQUEST'
same here!
The actual response code from google endpoint is 503 (Service Unavailable)
Apparantly they are now checking traffic rate and redirecting to:
https://ipv4.google.com/sorry/index?continue=https://translate.google.com/translate_a/single%3Fclient%3Dt%26sl%3Dauto%26tl%3Den%26hl%3Den%26dt%3Dat%26dt%3Dbd%26dt%3Dex%26dt%3Dld%26dt%3Dmd%26dt%3Dqca%26dt%3Drw%26dt%3Drm%26dt%3Dss%26dt%3Dt%26ie%3DUTF-8%26oe%3DUTF-8%26otf%3D1%26ssel%3D0%26tsel%3D0%26kc%3D5%26tk%3D495504.128489%26q%3Dhello&hl=en&q=EgSXUHjYGISU6dgFIhkA8aeDS9nxiL3i6-okEu2kNn24nPXxXsfwMgFy
Which Says: Our systems have detected unusual traffic from your computer network. Please try your request again later.
Temporary Solution:
- Setup a TOR HTTP Proxy: https://www.marcus-povey.co.uk/2016/03/24/using-tor-as-a-http-proxy/
- Use
tunnel
module from node packages to pass translate traffic from tor
var tunnel = require('tunnel');
...
...
}).then(function (url) {
return got(url, {
agent: tunnel.httpOverHttp({
proxy: {
host: 'localhost',
port: 8123
}
})
}).then(function (res) {
- Change tor IP address periodically
@nadalizadeh Your solution sounds great! But how can I force all of the translateService's traffic to go through the tor-proxy? Per request is yes! But the translateService has its own implementation of firing requests at the google-api endpoint! It would be nice, if we can have some kind of wrapper! Do you have any hint?
Same issues for me too.. How can I set a TOR proxy for a hosted bot.? LOL
Getting the same issues
{ Error at /Users/hucheng/hooper/bytedance/project/people-fe/recruitment-web/node_modules/google-translate-api/index.js:105:17 at process._tickCallback (internal/process/next_tick.js:68:7) code: 'BAD_REQUEST' }
this package uses got to request google translate: //add this to index.js var tunnel = require('tunnel'); var agent = tunnel.httpsOverHttp({ proxy: { host: 'localhost', port: 8123 } }); //change index.js:76 got(url,agent) //add this in tor config MaxCircuitDirtiness 10
this package uses got to request google translate: //add this to index.js var tunnel = require('tunnel'); var agent = tunnel.httpsOverHttp({ proxy: { host: 'localhost', port: 8123 } }); //change index.js:76 got(url,agent) //add this in tor config MaxCircuitDirtiness 10
would you consider adding a PR for that?
we need test this first.As in China, I found this solution not work.
Getting same issue.
Hey. Google tightened the restrictions and now from a single IP address can make very few queries. I added the use of a proxy server (IPv4, IPv6). Maybe my solution will help you.
https://github.com/extensionsapp/translatte
const translatte = require('translatte');
// Translate string to English using proxy
translatte('Вы говорите на русском?', {
from: 'ru',
to: 'en',
agents: [
'Mozilla/5.0 (Windows NT 10.0; ...',
'Mozilla/4.0 (Windows NT 10.0; ...',
'Mozilla/5.0 (Windows NT 10.0; ...'
],
proxies: [
'LOGIN:[email protected]:12345',
'LOGIN:[email protected]:54321'
]
}).then(res => {
console.log(res);
}).catch(err => {
console.error(err);
});
// { text: 'Do you speak Russian?',
// from: {
// language: {
// didYouMean: false,
// iso: 'ru'
// },
// text: {
// autoCorrected: false,
// value: '',
// didYouMean: false
// }
// },
// raw: '' }
I don't know why but on my ubuntu laptop the API works with tor, but when on Debian VPS I get bad request, I have the same config the 2 machines, do you guys have any idea what might cause the problem?
Hey. Google tightened the restrictions and now from a single IP address can make very few queries. I added the use of a proxy server (IPv4, IPv6). Maybe my solution will help you.
https://github.com/extensionsapp/translatte
const translatte = require('translatte'); // Translate string to English using proxy translatte('Вы говорите на русском?', { from: 'ru', to: 'en', agents: [ 'Mozilla/5.0 (Windows NT 10.0; ...', 'Mozilla/4.0 (Windows NT 10.0; ...', 'Mozilla/5.0 (Windows NT 10.0; ...' ], proxies: [ 'LOGIN:[email protected]:12345', 'LOGIN:[email protected]:54321' ] }).then(res => { console.log(res); }).catch(err => { console.error(err); }); // { text: 'Do you speak Russian?', // from: { // language: { // didYouMean: false, // iso: 'ru' // }, // text: { // autoCorrected: false, // value: '', // didYouMean: false // } // }, // raw: '' }
Tried this but ended up in getting below error - "SyntaxError: Unexpected token ..." at line no "translatte/node_modules/got/source/create.js:49"
I just did 'npm install translatte' and tried your example. Do I need to do anything else?
I just did 'npm install translatte' and tried your example. Do I need to do anything else?
It seems you are using older version of node.js than required for package. Please check node -v
.
I just did 'npm install translatte' and tried your example. Do I need to do anything else?
It seems you are using older version of node.js than required for package. Please check
node -v
.
I am using v8.4.0 node version. And now it is throwing me below error - Error at "/home/ubuntu/workspace/Hadoop/node_modules/translatte/index.js:141:17". Code: 'BAD_REQUEST'
may be google doing some updates on translator and current interaction become outdated? node 10, just installed and got BAD_REQUEST from begining. check few vpns (my private servers in different europe datacenters) to change public ip, but same result.
Same here, I received "BAD_REQUEST" error, What should I do?
I am using this for two BoTs running under Windows. I setup a Ubuntu v18 box yesterday with NodeJs. If I Stop the Windows BoTs and move / start them on the Ubuntu computer I receive bad request. I can move the BoT back to Windows and it works fine.
Same public IP Ipv4 address for both computers.
Try this solution from another issue. Maybe the reason of BAD_REQUEST is the same.
I don't know why but on my ubuntu laptop the API works with tor, but when on Debian VPS I get bad request, I have the same config the 2 machines, do you guys have any idea what might cause the problem?
Me too. and is this issue solved?
Try this solution from another issue. Maybe the reason of BAD_REQUEST is the same.
That worked perfectly. Thank you