Market data error

nickmanan
@sujith

Hi Sujith,
I'm getting below error while running code. Please help in resolving the error. I'm using V3 of kite connect.

2018-05-21 09:25:12+0530 [KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] Unhandled Error
Traceback (most recent call last):
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\python\log.py", line 103, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\python\log.py", line 86, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\python\context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\python\context.py", line 85, in callWithContext
return func(*args,**kw)
--- ---
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\internet\selectreactor.py", line 149, in _doReadOrWrite
why = getattr(selectable, method)()
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\internet\tcp.py", line 205, in doRead
return self._dataReceived(data)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\internet\tcp.py", line 211, in _dataReceived
rval = self.protocol.dataReceived(data)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\protocols\tls.py", line 330, in dataReceived
self._flushReceiveBIO()
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\protocols\tls.py", line 295, in _flushReceiveBIO
ProtocolWrapper.dataReceived(self, bytes)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\twisted\protocols\policies.py", line 120, in dataReceived
self.wrappedProtocol.dataReceived(data)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\autobahn\twisted\websocket.py", line 131, in dataReceived
self._dataReceived(data)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1175, in _dataReceived
self.consumeData()
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1187, in consumeData
while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1553, in processData
fr = self.onFrameEnd()
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1674, in onFrameEnd
self._onMessageEnd()
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\autobahn\twisted\websocket.py", line 159, in _onMessageEnd
self.onMessageEnd()
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 627, in onMessageEnd
self._onMessage(payload, self.message_is_binary)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\autobahn\twisted\websocket.py", line 162, in _onMessage
self.onMessage(payload, isBinary)
File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\kiteconnect-3.7.0b9-py3.6.egg\kiteconnect\ticker.py", line 71, in onMessage

File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\kiteconnect-3.7.0b9-py3.6.egg\kiteconnect\ticker.py", line 657, in _on_message

File "C:\Users\manan_r_jain\Anaconda3\lib\site-packages\kiteconnect-3.7.0b9-py3.6.egg\kiteconnect\ticker.py", line 781, in _parse_binary

builtins.OSError: [Errno 22] Invalid argument
  • girish400
    I'm getting same error
  • nickmanan
    nickmanan edited May 2018
    @girish400 do let me know if u are able to resolve it
  • nickmanan
    @vivek request your help
  • girish400
    ProgramData\Anaconda3\lib\site-packages\kiteconnect-3.7.0b11-py3.6.egg\kiteconnect\ticker.py", line 670, in _on_message

    File "C:\ProgramData\Anaconda3\lib\site-packages\kiteconnect-3.7.0b11-py3.6.egg\kiteconnect\ticker.py", line 794, in _parse_binary

    builtins.OSError: [Errno 22] Invalid argument

    2018-05-20 21:07:21,622 - kiteconnect.ticker - ERROR - Connection error: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    2018-05-20 21:07:21,622 - root - ERROR - closed connection on error: 1006 connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    2018-05-20 21:07:21,622 - kiteconnect.ticker - ERROR - Connection closed: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    2018-05-20 21:07:21,622 - root - ERROR - closed connection on close: 1006 connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    2018-05-20 21:07:21-0700 [KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] will retry in 2 seconds
    2018-05-20 21:07:21-0700 [-] Stopping factory
    2018-05-20 21:07:21-0700 [-] Main loop terminated.
  • girish400
    For MODE_QUOTE I'm receiving ticks but getting above error when MODE_FULL
  • rasp
    has any one got the solution
  • nickmanan
    no its not working at full mode , it worked at quote mode
  • Vivek
    @girish400 @nickmanan I am able to subscribe and get ticks with full mode. Please check if your callback code is fine. I will setup Anaconda env and check there also.
  • Vivek
    Also can you please list your subscriptions here?
  • nickmanan
    nickmanan edited May 2018
    @vivek its working in quote mode , so callback code is working fine .. i havent made any change to it anyway
  • girish400
    Attached list of tokens I'm subscribing to. In Mode_FULL mode when I subscribe to only one token I'm receiving ticks, but when subscribing to the attached list I'm getting an error.
  • girish400
    Above attached list of tokens is working in MODE_QUOTE and MODE_LTP
  • nickmanan
    nickmanan edited May 2018
    @girish400 did the problem got resolved ?
  • girish400
    Full mode is still a problem. It works for a while and then stops working.
  • girish400
    Dear Kite team,
    Why does the connection keep dropping?

    2018-05-30 14:46:09,291 - kiteconnect.ticker - DEBUG - pong => b''
    2018-05-30 14:46:11,525 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-30 14:46:11,525 - kiteconnect.ticker - DEBUG - last ping was 2.503096103668213 seconds back.
    2018-05-30 14:46:11,797 - kiteconnect.ticker - DEBUG - last pong was 2.505331039428711 seconds back.
    2018-05-30 14:46:11,797 - kiteconnect.ticker - DEBUG - pong => b''
    2018-05-30 14:46:14,029 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-30 14:46:14,029 - kiteconnect.ticker - DEBUG - last ping was 2.503247022628784 seconds back.
    2018-05-30 14:46:14,306 - kiteconnect.ticker - DEBUG - last pong was 2.5094387531280518 seconds back.
    2018-05-30 14:46:14,306 - kiteconnect.ticker - DEBUG - pong => b''
    2018-05-30 14:46:16,541 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-30 14:46:16,541 - kiteconnect.ticker - DEBUG - last ping was 2.5123918056488037 seconds back.
    2018-05-30 14:46:16,822 - kiteconnect.ticker - DEBUG - last pong was 2.515839099884033 seconds back.
    2018-05-30 14:46:16,822 - kiteconnect.ticker - DEBUG - pong => b''
    2018-05-30 14:46:19,047 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-30 14:46:19,047 - kiteconnect.ticker - DEBUG - last ping was 2.505790948867798 seconds back.
    2018-05-30 14:46:19,323 - kiteconnect.ticker - DEBUG - last pong was 2.500608444213867 seconds back.
    2018-05-30 14:46:19,323 - kiteconnect.ticker - DEBUG - pong => b''
    2018-05-30 14:46:21,557 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-30 14:46:21,557 - kiteconnect.ticker - DEBUG - last ping was 2.5102007389068604 seconds back.
    2018-05-30 14:46:21,830 - kiteconnect.ticker - DEBUG - last pong was 2.507664203643799 seconds back.
    2018-05-30 14:46:21,830 - kiteconnect.ticker - DEBUG - pong => b''
    2018-05-30 14:46:24,064 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-30 14:46:24,064 - kiteconnect.ticker - DEBUG - last ping was 2.506863832473755 seconds back.
    2018-05-30 14:46:24,338 - kiteconnect.ticker - DEBUG - last pong was 2.5077078342437744 seconds back.
    2018-05-30 14:46:24,338 - kiteconnect.ticker - DEBUG - pong => b''
    2018-05-30 14:46:26,573 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-30 14:46:26,573 - kiteconnect.ticker - DEBUG - last ping was 2.508545160293579 seconds back.
    2018-05-30 14:46:29,080 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-30 14:46:29,080 - kiteconnect.ticker - DEBUG - last ping was 2.5070996284484863 seconds back.
    2018-05-30 14:46:31,588 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-30 14:46:31,588 - kiteconnect.ticker - DEBUG - last ping was 2.5079848766326904 seconds back.
    2018-05-30 14:46:31,588 - kiteconnect.ticker - DEBUG - Last pong was 7.249576807022095 seconds ago. So dropping connection to reconnect.
    2018-05-30 14:46:31+0530 [-] dropping connection to peer tcp4:52.66.29.203:443 with abort=True: None
    2018-05-30 14:46:31,588 - kiteconnect.ticker - ERROR - Connection error: 1006 - connection was closed uncleanly (None)
    2018-05-30 14:46:31,588 - root - ERROR - closed connection on error: 1006 connection was closed uncleanly (None)
    2018-05-30 14:46:31,588 - kiteconnect.ticker - ERROR - Connection closed: 1006 - connection was closed uncleanly (None)
    2018-05-30 14:46:31,588 - root - ERROR - closed connection on close: 1006 connection was closed uncleanly (None)
    2018-05-30 14:46:31+0530 [-] will retry in 2 seconds
    2018-05-30 14:46:31+0530 [-] Stopping factory
    2018-05-30 14:46:31+0530 [-] Main loop terminated.
  • sujith
    It is trying to reconnect after closing the connection.
    Can you paste your on_error and on_close callback implementation?
  • girish400
    def on_close(ws, code, reason):
    logging.error("closed connection on close: {} {}".format(code, reason))
    ws.stop()


    def on_error(ws, code, reason):
    logging.error("closed connection on error: {} {}".format(code, reason))
    ws.stop()
  • sujith
    You shouldn't call ws.stop() unless you want actually stop the connection.
  • girish400
    ws.stop() was used to close the websocket once the kernel is restarted
  • nickmanan
    nickmanan edited July 2018
    @sujith web socket full mode is still a problem for me ! Please help me resolve the issue
  • abhi
    @sujith web socket full mode is still a problem. Quote and LTP mode are working fine.
  • sujith
    @abhi,
    Can you elaborate on the issue?
  • abhi
    @sujith I am trying to fetch live price for call and put options of NIFTY (150 in total) using WebSocket. This works fine in quote and ltp mode (ws.set_mode(ws.MODE_LTP, ticker_subscribe)). However, when I shift to full mode (ws.set_mode(ws.MODE_FULL, ticker_subscribe)) it throws up error similar to ones posted above.
  • rakeshr
    @abhi,
    Can you paste your code here?
    Once remove ws.close() from thread and check the error.
Sign In or Register to comment.