Each few minute getting below exception : kiteconnect.exceptions.NetworkException: Gateway is busy

dibya_1
Each time interval i am getting below error , dont know how to fix this issue.

Using latest api Kite Connect API version 3
Seems its existing issue.


Unhandled Error
Traceback (most recent call last):
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/python/log.py", line 103, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/python/log.py", line 86, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
--- ---
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
why = selectable.doRead()
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 205, in doRead
return self._dataReceived(data)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 211, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/protocols/tls.py", line 330, in dataReceived
self._flushReceiveBIO()
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/protocols/tls.py", line 295, in _flushReceiveBIO
ProtocolWrapper.dataReceived(self, bytes)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/protocols/policies.py", line 120, in dataReceived
self.wrappedProtocol.dataReceived(data)
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/twisted/websocket.py", line 131, in dataReceived
self._dataReceived(data)
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1175, in _dataReceived
self.consumeData()
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1187, in consumeData
while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1553, in processData
fr = self.onFrameEnd()
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1674, in onFrameEnd
self._onMessageEnd()
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/twisted/websocket.py", line 159, in _onMessageEnd
self.onMessageEnd()
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 627, in onMessageEnd
self._onMessage(payload, self.message_is_binary)
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/twisted/websocket.py", line 162, in _onMessage
self.onMessage(payload, isBinary)
File "build/bdist.linux-x86_64/egg/kiteconnect/ticker.py", line 71, in onMessage

File "build/bdist.linux-x86_64/egg/kiteconnect/ticker.py", line 657, in _on_message

File "/home/dibya/abstrade/src/absengine.py", line 2135, in on_ticks
trade.engine_strategy_gold_negative( ConfigGlobal.kite,ConfigGlobal.lstrategy[0] ,tick)
File "/home/dibya/abstrade/src/absengine.py", line 1853, in engine_strategy_gold_negative
records = init_trade_obj.get_historical_data(kite, dstrstegy)
File "/home/dibya/abstrade/src/__init__.py", line 374, in get_historical_data
return kite.historical_data(dtrade['INSTRUMENT_TOKEN'], str(dtrade['FROM_DATE']), str(dtrade['TO_DATE']),dtrade['INTERVAL'])
File "build/bdist.linux-x86_64/egg/kiteconnect/connect.py", line 604, in historical_data

File "build/bdist.linux-x86_64/egg/kiteconnect/connect.py", line 693, in _get

File "build/bdist.linux-x86_64/egg/kiteconnect/connect.py", line 762, in _request

kiteconnect.exceptions.NetworkException: Gateway is busy

Unhandled Error
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/kiteconnect/ticker.py", line 521, in connect

File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/base.py", line 1261, in run
self.mainLoop()
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/base.py", line 1273, in mainLoop
self.doIteration(t)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/epollreactor.py", line 235, in doPoll
log.callWithLogger(selectable, _drdw, selectable, fd, event)
--- ---
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/python/log.py", line 103, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/python/log.py", line 86, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 627, in _doReadOrWrite
self._disconnectSelectable(selectable, why, inRead)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 258, in _disconnectSelectable
selectable.connectionLost(failure.Failure(why))
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 475, in connectionLost
self._commonConnection.connectionLost(self, reason)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 289, in connectionLost
protocol.connectionLost(reason)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/protocols/tls.py", line 398, in connectionLost
self._flushReceiveBIO()
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/protocols/tls.py", line 295, in _flushReceiveBIO
ProtocolWrapper.dataReceived(self, bytes)
File "/home/dibya/.local/lib/python2.7/site-packages/twisted/protocols/policies.py", line 120, in dataReceived
self.wrappedProtocol.dataReceived(data)
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/twisted/websocket.py", line 131, in dataReceived
self._dataReceived(data)
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1175, in _dataReceived
self.consumeData()
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1187, in consumeData
while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1545, in processData
fr = self.onFrameData(payload)
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1639, in onFrameData
self._onMessageFrameData(payload)
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/twisted/websocket.py", line 150, in _onMessageFrameData
self.onMessageFrameData(payload)
File "/home/dibya/.local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 601, in onMessageFrameData
self.frame_data.append(payload)
exceptions.AttributeError: 'NoneType' object has no attribute 'append'
  • dibya_1
    Can any one please help me regarding the above issue ?
  • phantomdrake
    Yeah same here. Such a beautiful infrastructure they have.
  • phantomdrake
    This is after rate limiting BTW.
  • dibya_1

    kiteconnect.exceptions.DataException: Couldn't parse the JSON response received from the server:
    502 Bad Gateway

    502 Bad Gateway



    nginx/1.10.3 (Ubuntu)



  • sujith
    Can you add more details?
    which API call is throwing this error? How often do you make this API call?
    What are the params you are sending? What version of pykiteconnect are you using?

    Please don't expect people to spend time on this if you are partially posting the query.

    @phantomdrake,
    Please stop spamming other threads, if you have an issue post a new thread with complete details, we will look into the issue.
  • dibya_1
    Hi, i am getting exception for kite.historical_data()
    I am calling this api each 5 seconds
    I am using kite connect version 3

    it works fine for some time and after it throws an exception .
    kiteconnect.exceptions.NetworkException: Gateway is busy
    and at the end it stops with
    exceptions.AttributeError: 'NoneType' object has no attribute 'append'

    Please try to help me on this , i am getting stock from few days .

    return kite.historical_data(dtrade['INSTRUMENT_TOKEN'], str(dtrade['FROM_DATE']), str(dtrade['TO_DATE']),dtrade['INTERVAL'])
  • sujith
    @dibya_1,
    We will look into this.

    But for the live strategies, we don't recommend using historical data API. You need to generate candles at your end using the live market data provided via websockets. You can check out this this thread to get started.
Sign In or Register to comment.