Error: connect ETIMEDOUT 92.53.120.74:443 at TCPConnectWrap.afterConnect [as oncomplete] when using clist.by API

Viewed 1731

I started getting the error after using the clist.by website's API for 3-4 days (via NodeJs). I have been trying to find a solution but couldn't get one anywhere. I read somewhere that port 443 issues can be due to a proxy server but i ain't using one. Can someone please help? It will be much appreciated. Code is as follows:

const axios = require("axios");
var mongoose = require("mongoose");

var eventSchema = new mongoose.Schema({
  eventId: Number
});

var Event = mongoose.model("Event",eventSchema);

const {google} = require("googleapis");
const {OAuth2} = google.auth;
const oAuth2Client = new OAuth2('......','......'); 
oAuth2Client.setCredentials({
  refresh_token: '.......'  
});
const calendar = google.calendar({version: 'v3' , auth: oAuth2Client})

var URL = "https://clist.by/api/v1/json/contest/?resource__name=codechef.com&start__gt=2020-6-21T00%3A00%3A00&&end__lt=2020-6-25T22%3A59%3A59&username=<myusername>&api_key=<my_api_key>";

axios.get(URL)
.then(function (response) {
for( var i=0 ; i<1 ; i++)  
{    
  Event.findOne({ eventId: response.data.objects[i].id }, function(err, result) {
    if (err) {
      console.log("THIS IS YOUR ERROR in event function"+err);
    } else {
      if( result === null)
      {
         const event = {
         summary: String(response.data.objects[i].event),
         description: 'CodeChef',
         start:{
            dateTime: response.data.objects[i].start,
            timeZone: 'Asia/Kolkata',
         },
         end:{
            dateTime: response.data.objects[i].end,
            timeZone: 'Asia/Kolkata',
         },
       }
       calendar.events.insert({calendarId : '<calendarID>',resource: event},       err => {
         if(err) return console.error('Calendar event creation error: ',err);
         console.log('Calendar event created!');
       }); //calendar event ended

       var identification = response.data.objects[i].id;
       var newEvent = new Event({
         eventId: identification
       });
       newEvent.save(function(err) {
       if (err) 
       {
        console.log("ERROR IN SAVING EVENT CODE "+err);
       }  
       console.log('EventId successfully saved.');
       });
      } //if inside else ends 
      else
      {
        console.log("Event already present!");
      }    // else inside else ends 
    }     //Event.findOne else ends
  });    //Event.findOne ends  
}       //end of for loop
})     //end of .then

.catch(function (error) {
  console.log("API URL "+error);
});

module.exports = {calendar}; 

I am getting , all of this as my error-

 API URL Error: connect ETIMEDOUT 92.53.120.74:443  at TCPConnectWrap.afterConnect [as oncomplete]  (net.js:1106:14)
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '92.53.120.74',
  port: 443,
  config:
   { url:
      'https://clist.by/api/v1/json/contest/?resource__name=codechef.com&start__gt=2020-6-22T00%3A00%3A00&&end__lt=2020-6-25T23%3A59%3A59&username=<username>&api_key=<api_key>',
     method: 'get',
     headers:
      { Accept: 'application/json, text/plain, */*',
        'User-Agent': 'axios/0.19.2' },
     transformRequest: [ [Function: transformRequest] ],
     transformResponse: [ [Function: transformResponse] ],
     timeout: 0,
     adapter: [Function: httpAdapter],
     xsrfCookieName: 'XSRF-TOKEN',
     xsrfHeaderName: 'X-XSRF-TOKEN',
     maxContentLength: -1,
     validateStatus: [Function: validateStatus],
     data: undefined },
  request:
   Writable {
     _writableState:
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: false,
        needDrain: false,
        ending: false,
        ended: false,
        finished: false,
        destroyed: false,
        decodeStrings: true,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: true,
        bufferProcessing: false,
        onwrite: [Function: bound onwrite],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: false,
        errorEmitted: false,
        emitClose: true,
        autoDestroy: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: true,
     _events:
      [Object: null prototype] {
        response: [Function: handleResponse],
        error: [Function: handleRequestError] },
     _eventsCount: 2,
     _maxListeners: undefined,
     _options:
      { protocol: 'https:',
        maxRedirects: 21,
        maxBodyLength: 10485760,
        path:
         '/api/v1/json/contest/?resource__name=codechef.com&start__gt=2020-6-22T00%3A00%3A00&&end__lt=2020-6-25T23%3A59%3A59&username=<username>&api_key=<api_key>',
        method: 'GET',
        headers: [Object],
        agent: undefined,
        agents: [Object],
        auth: undefined,
        hostname: 'clist.by',
        port: null,
        nativeProtocols: [Object],
        pathname: '/api/v1/json/contest/',
        search:
         '?resource__name=codechef.com&start__gt=2020-6-22T00%3A00%3A00&&end__lt=2020-6-25T23%3A59%3A59&username=<username>&api_key=<api_key>' },
     _redirectCount: 0,
     _redirects: [],
     _requestBodyLength: 0,
     _requestBodyBuffers: [],
     _onNativeResponse: [Function],
     _currentRequest:
      ClientRequest {
        _events: [Object],
        _eventsCount: 6,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: false,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [TLSSocket],
        connection: [TLSSocket],
        _header:
         'GET /api/v1/json/contest/?resource__name=codechef.com&start__gt=2020-6-22T00%3A00%3A00&&end__lt=2020-6-25T23%3A59%3A59&username=<username>&api_key=<api_key> HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nUser-Agent: axios/0.19.2\r\nHost: clist.by\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Agent],
        socketPath: undefined,
        timeout: undefined,
        method: 'GET',
        path:
         '/api/v1/json/contest/?resource__name=codechef.com&start__gt=2020-6-22T00%3A00%3A00&&end__lt=2020-6-25T23%3A59%3A59&username=<username>&api_key=<api_key>',
        _ended: false,
        res: null,
        aborted: undefined
0 Answers
Related