Connection error in NodeJs API

MW5790
I am running a loop that checks for group of 20 stocks LTP and then executes trade using some calculations. this program is set to run continously. once in 30 minutes, i get a {"message":"No response from server with error code: ECONNABORTED","error_type":"NetworkException","data":null}

I make the following kitconnect calls using Nodejs API inside my for loop.
I notice that this error happens just after getLTP call.

How to debug and resolve

for (index=0; index<zones.length; index++)
{
kiteconnect.getLTP();
kc.getQuote();

kc.placeOrder();


}
  • sujith
    Can you run in debug mode and let us know for which API call you got this error?
    Make sure to paste the complete stack trace and remove the app and client-specific details from that.
  • MW5790
    this is the error message -- {"message":"No response from server with error code: ECONNABORTED","error_type":"NetworkException","data":null}
    This error is thrown before call to kiteconnect.getLTP

    Should debug be enabled in the options hash paramter that initiates the kiteconnect object.

    var options = {
    "api_key": "",
    "debug": false // true here ??
    };
  • sujith
    Yes, you need to set the debug flag true is while creating the Kite Connect object. You can check out the js documentation here.
  • MW5790
    here is the trace . please help as this is getting very frequent 7 times a day on average.

    {
    adapter: [Function: httpAdapter],
    transformRequest: { '0': [Function: transformRequest] },
    transformResponse: { '0': [Function: transformResponse] },
    timeout: 7000,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    validateStatus: [Function: validateStatus],
    headers: {
    common: { Accept: 'application/json, text/plain, */*' },
    delete: {},
    get: {},
    head: {},
    post: { 'Content-Type': 'application/x-www-form-urlencoded' },
    put: { 'Content-Type': 'application/x-www-form-urlencoded' },
    patch: { 'Content-Type': 'application/x-www-form-urlencoded' },
    'X-Kite-Version': 3,
    'User-Agent': 'kiteconnectjs/3.1.0',
    Authorization: '**********************'
    },
    baseURL: 'https://api.kite.trade',
    paramsSerializer: [Function: paramsSerializer],
    method: 'get',
    url: '/quote/ltp',
    params: { i: 'NSE:ASIANPAINT' },
    data: ''
    }
    /**this is application log entry that comes in the debug log**/
    2020-07-27 17:04:43.403 INFO Iteration - 9 - symbol NSE:ASIANPAINT Zone -103
    2020-07-27 17:04:50.408 ERROR Error -{"message":"No response from server with error code: ECONNABORTED","error_type":"NetworkException","data":null}

    /**this is application log entry that comes in the debug log**/




  • sujith
    You can refer to this thread.
  • MW5790
    In my case this is happening on reads. today it happened 20 times in 3 minutes. i am running Nodejs code from a regular AWS Ec2 instance. today i had to stop the code from executing as it flooded my SMS alerts. no order execution. Just invoking getLTP in a loop across instruments. how do I handle such errors as it could lead to crucial trade miss ?
  • sujith
    If you are polling for LTP then I would suggest using the Websocket API.
  • MW5790
    MW5790 edited August 2020
    Hi Sujith that is a very tedious program. any sample code. isnt that what your client library is doing under the hood ?

    today even when I ran it once from command line it errored out. at 18:45 IST - 31Jul

    {
    adapter: [Function: httpAdapter],
    transformRequest: { '0': [Function: transformRequest] },
    transformResponse: {
    '0': [Function: transformResponse],
    '1': [Function: formatResponse]
    },
    timeout: 7000,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    validateStatus: [Function: validateStatus],
    headers: {
    common: { Accept: 'application/json, text/plain, */*' },
    delete: {},
    get: {},
    head: {},
    post: { 'Content-Type': 'application/x-www-form-urlencoded' },
    put: { 'Content-Type': 'application/x-www-form-urlencoded' },
    patch: { 'Content-Type': 'application/x-www-form-urlencoded' },
    'X-Kite-Version': 3,
    'User-Agent': 'kiteconnectjs/3.1.0',
    Authorization: 'token bejtlvvs809o3qxb:V2GPPnPOVg09098wQxBpo17srRKwW9gb4M'
    },
    baseURL: 'https://api.kite.trade',
    paramsSerializer: [Function: paramsSerializer],
    method: 'get',
    url: '/orders',
    params: {},
    data: ''
    }
    2020-07-31 19:18:24.331 ERROR uncaught error in main logic {"message":"No response from server with error code: ECONNABORTED","error_type":"NetworkException","data":null}

    This is surely some issue with your OMS somewhere. i am considering migrating to another platform if I can't find a reasonable fix.
  • sujith
    Are you sending the request for all instruments at once or you are sending one call for each instrument?
  • MW5790
    one call for each instrument.
  • sujith
    You can combine and make one request.
Sign In or Register to comment.