plainheart / bing-translate-api

A simple and free API for Bing & Microsoft Translator for Node.js
https://github.com/plainheart/bing-translate-api
MIT License
161 stars 28 forks source link

why my requset say ,Not response many reqsuet ? #10

Closed rebazomar121 closed 2 years ago

rebazomar121 commented 2 years ago

I'm blocked when I use bing-translator-API, so I try using a proxy for my server but it uses (got) to send API, and don't have an idea how to set proxy with this (got).

plainheart commented 2 years ago

Hi, I think it may be better to expose the proxy option agent of got. Will do it later.

rebazomar121 commented 2 years ago

Hi, I think it may be better to expose the proxy option agent of got. Will do it later.

Hi, I try agent but it doesn't work, can I send data via Axios or request or just we can use got, I try it doesn't work , so now I want to change the proxy for around 30 days I'm searching to it but i can't find any way to fix it, if you can get me peace of this got request with using proxy, i try it const { body } = await got.post("http://ip-api.com/json", { headers: requestHeaders, body: requestBody, responseType: 'json', }, { agent: { https: new HttpProxyAgent({ keepAlive: true, keepAliveMsecs: 1000, maxSockets: 256, maxFreeSockets: 256, scheduling: 'lifo', proxy: proxyUrl }) } }) but it doesn't work

plainheart commented 2 years ago

It's a bit strange that agent doesn't work. It seems you were configuring the agent incorrectly.

I tried this and it works.

const { body } = await got.post('http://ip-api.com/json', {
    // headers: requestHeaders,
    // body: requestBody,
    responseType: 'json',
    agent: {
      http: new HttpProxyAgent({
        keepAlive: true,
        keepAliveMsecs: 1000,
        maxSockets: 256,
        maxFreeSockets: 256,
        scheduling: 'lifo',
        proxy: 'PROXY ENDPOINT'
      })
    }
  })
plainheart commented 2 years ago

Released v2.4.0 on npm.

rebazomar121 commented 2 years ago

thank for you it doesn't work for me so I try this code

const { bootstrap } = require('global-agent');
process.env.GLOBAL_AGENT_HTTP_PROXY = proxyUrl;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = false;
bootstrap();

after that, I did write this inside got

    https: {
      rejectUnauthorized: false
    },

now it working.......