google-translate-api
google-translate-api copied to clipboard
Error on request..
Hi Matheuss,
I have this error on request to google translate without api key,
what does it mean?:
{ Error: socket hang up at TLSSocket.onHangUp (_tls_wrap.js:1124:19) at TLSSocket.g (events.js:292:16) at emitNone (events.js:91:20) at TLSSocket.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9) code: 'ECONNRESET' }
thanks for your answer :)
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: '' }