Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5962

Got "ETIMEDOUT" error when calling api from docker container with axios

$
0
0

I'm trying to scrape a website and send an alert to Telegram after scraping. It was working in the local environment without Docker. After setting it up with Docker, I started getting a "ETIMEDOUT" error while sending alert. I'm confused why this error is happening since I can still scrape the website. I've tried restarting the container and adding Google DNS, but it's still not working consistently. Sometimes, it works for a couple of tries and then keeps failing. I am quite sure that the url is correct too. My os is Ubuntu.

I made some testing with other api. It's working when I call google.com and jsonplaceholder. Not working only with telegram bot api. The domain is https://api.telegram.org. Others said to use proxy. But I live in Thailand and can't even call from my local docker container.

Here's my Axios code and the error message.

  async sendToTelegram(text: string) {    let token = process.env.TELEGRAM_BOT_TOKEN;    let url = `https://api.telegram.org/bot${token}/sendMessage`;    console.log(url);    let group_id = process.env.TELEGRAM_GROUP_ID;    let params = {        chat_id: group_id ? group_id : "",        text    };    await axios.get(url, { params });}

enter image description here


Viewing all articles
Browse latest Browse all 5962

Trending Articles