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

BAD_REQUEST response #70

Open
kyotin opened this issue Jun 4, 2018 · 25 comments
Open

BAD_REQUEST response #70

kyotin opened this issue Jun 4, 2018 · 25 comments

Comments

@kyotin
Copy link

kyotin commented Jun 4, 2018

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.

@HigisBig
Copy link

HigisBig commented Jun 5, 2018

Yeah I've recently been getting this issue as well

1 similar comment
@easonlovejiven
Copy link

Yeah I've recently been getting this issue as well

@wowdyaln
Copy link

wowdyaln commented Jun 7, 2018

node_modules/google-translate-api/index.js:105:17  at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7) code: 'BAD_REQUEST'

@tonistair
Copy link

same here!

@nadalizadeh
Copy link

nadalizadeh commented Jun 8, 2018

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.

@nadalizadeh
Copy link

Temporary Solution:

  1. Setup a TOR HTTP Proxy:
    https://www.marcus-povey.co.uk/2016/03/24/using-tor-as-a-http-proxy/
  2. 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) {

  1. Change tor IP address periodically

@davidrocket
Copy link

@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?

@mohasin69
Copy link

mohasin69 commented Jul 23, 2018

Same issues for me too..
How can I set a TOR proxy for a hosted bot.? LOL

@cocoacorgi
Copy link

Getting the same issues

@hooper-hc
Copy link

{ 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' }

@genostack
Copy link

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

@jahglow
Copy link

jahglow commented Sep 20, 2018

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?

@genostack
Copy link

we need test this first.As in China, I found this solution not work.

@nvtuan305
Copy link

Getting same issue.

@extensionsapp
Copy link

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: '' }

@Tahakun
Copy link

Tahakun commented Sep 26, 2018

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?

@lokeshjain09
Copy link

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?

@vitalets
Copy link

vitalets commented Oct 4, 2018

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.

@lokeshjain09
Copy link

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'

@abrakadobr
Copy link

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.

@sadra
Copy link

sadra commented Oct 25, 2018

Same here, I received "BAD_REQUEST" error, What should I do?

@urPlaceOrMine
Copy link

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.

@vitalets
Copy link

Try this solution from another issue. Maybe the reason of BAD_REQUEST is the same.

@martin-matj
Copy link

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?

@urPlaceOrMine
Copy link

Try this solution from another issue. Maybe the reason of BAD_REQUEST is the same.

That worked perfectly. Thank you

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