Parsing error

girish400
Parsing error in Full mode for below tokens

tokens =[12864514, 12906242, 12889858, 12843266, 12870914, 12888834, 12907522, 12875778, 12866562, 12850434, 12868610, 12873986, 12853250, 12887042, 12845058, 12884226, 12849154, 12856578, 12908034, 12893442, 12892418, 12865282, 12905986, 12887810, 12866050, 12883970, 12869634, 12896514, 12868354, 12868866, 12899586, 12902658, 12877314, 12878082, 12870658, 12882434, 12848898, 12894466, 12903938, 12900610, 12893954, 12899074, 12885250, 12866306, 12899842, 12905218, 12904706, 12889346, 12865538, 12910338, 12880642, 12850178, 12897538, 12854018, 12874498, 12844290, 12882178, 12879618, 12889090, 12858370, 12843522, 12871170, 12852994, 12845570, 12881154, 12902914, 12847874, 12850690, 12869378, 12869890, 12896002, 12900866, 12892674, 12891394, 12875010, 12906754, 12899330, 12867586, 12878594, 12898050, 12870402, 12883202, 12856066, 12867842, 12849666, 12844546, 12911362, 12888066, 12880386, 12877826, 12885506, 12910082, 12856834, 12843778, 12844034, 12873218, 12906498, 12871426, 12867330, 12909826, 12909570, 12892162, 12897282, 12851202, 12898306, 12845826, 12880898, 12835330, 12890882, 12860930, 12905730, 12849922, 12891138, 12874242, 12888578, 12854530, 12877570, 12901122, 12876290, 12894210, 12882690, 12861954, 12895746, 12878338, 12856322, 12904450, 12883714, 12848130, 12904194, 12909058, 12841474, 12872450, 12890114, 12868098, 12903426, 12907266, 12846338, 12907010, 12882946, 12903682, 12875522, 12878850, 12901634, 12850946, 12843010, 12901890, 12896770, 12861698, 12905474, 12900354, 12854786,12897026, 12857602, 12896258, 12873474, 12877058, 12871682, 12845314, 12870146, 12844802, 12866818, 12908290, 12895490, 12890370, 12901378, 12859650, 12874754, 12904962, 12873730, 12860674, 12894722, 12875266, 12897794, 12857858, 12881922, 12907778, 12849410, 12887554, 12865794, 12835586, 12889602, 12867074, 12879106, 12888322, 12872706, 12894978, 12859906, 12886786, 12842242, 12862978, 12871938, 12910850, 12890626, 12895234, 12876034, 12903170, 12876802, 12883458, 12872194, 12902146, 12911874, 12900098, 12872962, 12858114, 12910594, 12911106, 12864258, 12862722, 12854274, 12902402]

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

File "C:\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
  • girish400
    After reconnection and subscribing for only one token, the first tick was received on 2018-05-31 09:15:08.


    2018-05-31 09:15:01,674 - kiteconnect.ticker - ERROR - Connection error: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    2018-05-31 09:15:01,675 - root - ERROR - closed connection on error: 1006 connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    2018-05-31 09:15:01,675 - kiteconnect.ticker - ERROR - Connection closed: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    2018-05-31 09:15:01,675 - root - ERROR - closed connection on close: 1006 connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    2018-05-31 09:15:01+0530 [KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] will retry in 2 seconds
    2018-05-31 09:15:01+0530 [-] Stopping factory
    2018-05-31 09:15:04+0530 [-] Starting factory

    2018-05-31 09:15:05,560 - root - DEBUG - on connect: {"peer": "tcp4:52.66.29.203:443", "headers": {"date": "Thu, 31 May 2018 03:45:05 GMT", "connection": "upgrade", "upgrade": "websocket", "sec-websocket-accept": "fO1SQJu9mgW/Sq+dQnCKb6dZ/rI="}, "version": 18, "protocol": null, "extensions": []}
    2018-05-31 09:15:05,561 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-31 09:15:05,561 - kiteconnect.ticker - DEBUG - Resubscribe and set mode: full - [12901122]
    2018-05-31 09:15:05,845 - kiteconnect.ticker - DEBUG - pong => b''
    2018-05-31 09:15:08,061 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-31 09:15:08,061 - kiteconnect.ticker - DEBUG - last ping was 2.500702142715454 seconds back.
    2018-05-31 09:15:08,340 - kiteconnect.ticker - DEBUG - last pong was 2.494687080383301 seconds back.
    2018-05-31 09:15:08,341 - kiteconnect.ticker - DEBUG - pong => b''
    2018-05-31 09:15:10,563 - kiteconnect.ticker - DEBUG - ping =>
    2018-05-31 09:15:10,563 - kiteconnect.ticker - DEBUG - last ping was 2.500699281692505 seconds back.
    2018-05-31 09:15:10,845 - kiteconnect.ticker - DEBUG - last pong was 2.5034971237182617 seconds back.
    2018-05-31 09:15:10,845 - kiteconnect.ticker - DEBUG - pong => b''
  • sujith
    Can you let us know what version of pykiteconnect are you using?
  • girish400
    kiteconnect-3.7.0-py3.6.egg (3.7.0)
  • girish400
    2018-06-01 11:04:18+0530 [KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] Unhandled Error
    Traceback (most recent call last):
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\python\log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\python\log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\python\context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\python\context.py", line 85, in callWithContext
    return func(*args,**kw)
    --- ---
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\selectreactor.py", line 149, in _doReadOrWrite
    why = getattr(selectable, method)()
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\tcp.py", line 205, in doRead
    return self._dataReceived(data)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\tcp.py", line 211, in _dataReceived
    rval = self.protocol.dataReceived(data)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\protocols\tls.py", line 330, in dataReceived
    self._flushReceiveBIO()
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\protocols\tls.py", line 295, in _flushReceiveBIO
    ProtocolWrapper.dataReceived(self, bytes)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\protocols\policies.py", line 120, in dataReceived
    self.wrappedProtocol.dataReceived(data)
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\twisted\websocket.py", line 131, in dataReceived
    self._dataReceived(data)
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1175, in _dataReceived
    self.consumeData()
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1187, in consumeData
    while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1553, in processData
    fr = self.onFrameEnd()
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1674, in onFrameEnd
    self._onMessageEnd()
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\twisted\websocket.py", line 159, in _onMessageEnd
    self.onMessageEnd()
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 627, in onMessageEnd
    self._onMessage(payload, self.message_is_binary)
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\twisted\websocket.py", line 162, in _onMessage
    self.onMessage(payload, isBinary)
    File "C:\ProgramData\Anaconda3\lib\site-packages\kiteconnect-3.7.0-py3.6.egg\kiteconnect\ticker.py", line 71, in onMessage

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

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

    builtins.OSError: [Errno 22] Invalid argument

    2018-06-01 11:04:18,999 - kiteconnect.ticker - ERROR - Connection error: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    2018-06-01 11:04:19,000 - kiteconnect.ticker - ERROR - Connection closed: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)

    tokens= [ 9842178, 9843458, 9843714, 9843970, 9844738, 9844994, 9845250, 9845506, 9846786, 9847042, 9847810, 9848066, 9850370, 9850626, 9851906, 9852162, 9853442, 9853698, 9855234, 9855490, 9857026, 9857794, 9860610, 9860866, 9864706, 9864962, 9872386, 9872642, 9872898, 9873154, 9873922, 9874178, 9874690, 9876226, 9877506, 9877762, 9879810, 9880066, 9880322, 9880578, 9882882, 9883138, 9884418, 9884674, 9885186, 9885442, 9885954, 9886466, 9886722, 9886978, 9887746, 9888002, 9888514, 9889538, 9889794, 9890050, 9890306, 9890562, 9890818, 9891074, 9891330, 9891586, 9891842, 9892098, 9892354, 9894146, 8972546, 8974082, 10078722, 10078978, 10079234, 10082306, 10284546, 10284802, 10694402, 10694658, 8993794, 8994818, 9308162, 9310466, 9528578, 9529346, 10008578, 10008834, 10009090, 10009346, 10009602, 10009858, 10130178, 10130434, 10130690, 10131970, 10232322, 10232834, 9416962, 9420802, 9517826, 9519874, 10606594, 10606850, 11539714, 11540482, 9468674, 11454978, 9310978, 9311234, 9311490, 9311746, 10914562, 10918146, 10439938, 10440450, 10440706, 10443266, 10443522, 10444290, 10444546, 10444802, 10445058, 10446082, 10447362, 10447874, 10448130, 10448642, 10449666, 10453506, 10454274, 10455298, 10455554, 10455810, 10456834, 10457346, 10458370, 10459138, 10459906, 10460162, 10460930, 10462466, 10462722, 10462978, 10467074, 10471170, 10471426, 10471938, 10472194, 10472962, 10473218, 10475010, 10475778, 10476034, 10477058, 10477314, 10477570, 10477826, 10478082, 10478338, 10479362, 10486530, 10487810, 10488834, 10489090, 10491906, 10492418, 10495234, 10495490, 10495746, 10496002, 10496258, 10496514, 10500610, 10500866, 10502402, 10502658, 10504194, 10504450, 10504706, 10694914, 10695170, 8995074, 9002754, 9310722, 9312258, 9530114, 9530370, 10010114, 10010370, 10010626, 10012162, 10012418, 10012674, 10132226, 10132482, 10132994, 10133250, 10235394, 10235650, 9529602, 9529858, 9990658, 9994498, 10611202, 10611458, 11540738, 11542018, 9682178, 9682434, 9682690, 9683714, 12657922, 12661250, 12661506, 12662274, 12663554, 12663810, 12664066, 12665346, 12665602, 12666626, 12666882, 12667906, 12668162, 12671490, 12671746, 12673026, 12673282, 12676354, 12676610, 12677122, 12678402, 12678914, 12679170, 12682498, 12684546, 12685826, 12686082, 12687362, 12687874, 12689154, 12689410, 12690178, 12690434, 12694018, 12694274, 12695554, 12695810, 12701186, 12701442, 12707330, 12707586, 12712450, 12714754, 12721666, 12723458, 12725762, 12726018, 12726274, 12727042, 12731906, 12732162, 12734210, 12734722, 12734978, 12735746, 12736002, 12736258, 12736514, 12736770, 12737026, 12737282, 12738562, 12738818, 12739074, 12739330, 12739586, 9470210, 9470978, 9471234, 9471490, 9894402, 9894658, 9896450, 9897218, 9897474, 9897730, 8977922, 8982530, 10082818, 10085890, 10086146, 10088194, 10285314, 10286082, 10695426, 10700034, 9011202, 9011458, 9316866, 9317122, 9535490, 9535746, 10014722, 10014978, 10015490, 10015746, 10016002, 10016258, 10135810, 10136066, 10136322, 10136834, 10238978, 10239234, 10117122, 10120194, 10122754, 10123010, 10613762, 10614018, 11544066, 11544322, 11455490, 11455746, 9312002, 9312514, 9317634, 9319170, 10974466, 10974722, 10974978, 10975746, 10976770, 10977026, 10977794, 10978050, 10980098, 10981378, 10981890, 10982146, 10982402, 10982658, 10984194, 10984450, 10985218, 10985730, 10985986, 10986498, 10986754, 10987010, 10987266, 10987522, 10987778, 10988290, 10990338, 10990594, 10990850, 10991106, 10991362, 10991618, 10991874, 10992130, 10992898, 10993154, 10994946, 10995202, 10995458, 10995714, 10995970, 10996226, 10996482, 10996994, 10997250, 10997506, 10998274, 10999810, 11000066, 11000322, 11000578, 11000834, 11001090, 11002114, 11003394, 11004418, 11004674, 11004930, 11005186, 11005442, 11005698, 11005954, 11006466, 11007490, 11008002, 11008258, 9003010, 9007362, 9007618, 9008898, 9009154, 9010690, 9315586, 9316610, 9534722, 9534978, 10012930, 10013186, 10013442, 10013698, 10014210, 10014466, 10133762, 10134018, 10134274, 10134530, 10236930, 10237698, 9994754, 9995778, 9996034, 9996290, 10611714, 10612482, 11543042, 11543810]
  • girish400
    @sujith can you please test at your end with all these tokens in Full mode?
  • zartimus
    @girish400 Works fine. Can you post the code?
  • girish400
    girish400 edited June 2018
    r = redis.Redis(host='127.0.0.1',port=6379,db=1)

    kite = KiteConnect(api_key = s.api_key())

    api_key = XXXXXX
    access_token = XXXXXX

    kws = KiteTicker(api_key, access_token, debug=True)

    def on_ticks(ws, ticks):
    r.lpush("Ticks-FULL",ticks)

    def on_connect(ws, response):
    ws.subscribe(tokens)
    ws.set_mode(ws.MODE_FULL, tokens)

    kws.on_ticks = on_ticks
    kws.on_connect = on_connect
    kws.connect(threaded=True)
  • girish400
    @zartimus, when the tick program is started before market open's, I'm still getting the same error. Please fix the ticker program.
  • zartimus
    zartimus edited June 2018
    @girish400 the code looks fine. Are you saying this happens just before the market open's? How do we replicate this on our end?
  • girish400
    Run the ticker program in FULL MODE few minutes before the market opens.

    I'm using below tokens

    tokens=[9843458, 9844994, 9853698, 9872642, 9880066, 9880578, 9883138, 9884674, 9885442, 9886466, 9886978, 9888002, 9889538, 9890050, 9890306, 9890562, 9891074, 9891586, 9891842, 9892098, 9892354, 9894146, 8972546, 8974082, 10078722, 10078978, 10079234, 10082306, 10284546, 10284802, 10694402, 10694658, 8993794, 8994818, 9308162, 9310466, 9528578, 9529346, 10008578, 10008834, 10009090, 10009602, 10130178, 10130690, 10232322, 9416962, 9517826, 10606594, 11539714, 12298498, 10488834, 10500610, 8995074, 10012418, 9990658, 12687362, 12701186, 12726274, 12736514, 9470210, 9470978, 9471490, 9894658, 9897218, 9897730, 8977922, 8982530, 10082818, 10085890, 10086146, 10088194, 10285314, 10286082, 10695426, 9011202, 9011458, 9316866, 9535490, 10014722, 10015490, 10016002, 10135810, 10238978, 10122754, 11544066,12312066]

    2018-06-06 09:03:29,594 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.kite.trade
    2018-06-06 09:03:30,705 - urllib3.connectionpool - DEBUG - https://api.kite.trade:443 "POST /session/token HTTP/1.1" 200 None
    2018-06-06 09:03:35,294 - root - DEBUG - on connect: {"peer": "tcp4:52.66.29.203:443", "headers": {"date": "Wed, 06 Jun 2018 03:33:35 GMT", "connection": "upgrade", "upgrade": "websocket", "sec-websocket-accept": "8Y5SfknnNFPds0aosWINzAjx+AU="}, "version": 18, "protocol": null, "extensions": []}
    Unhandled Error
    Traceback (most recent call last):
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\python\log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\python\log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\python\context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\python\context.py", line 85, in callWithContext
    return func(*args,**kw)
    --- ---
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\selectreactor.py", line 149, in _doReadOrWrite
    why = getattr(selectable, method)()
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\tcp.py", line 205, in doRead
    return self._dataReceived(data)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\tcp.py", line 211, in _dataReceived
    rval = self.protocol.dataReceived(data)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\protocols\tls.py", line 330, in dataReceived
    self._flushReceiveBIO()
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\protocols\tls.py", line 295, in _flushReceiveBIO
    ProtocolWrapper.dataReceived(self, bytes)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\protocols\policies.py", line 120, in dataReceived
    self.wrappedProtocol.dataReceived(data)
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\twisted\websocket.py", line 131, in dataReceived
    self._dataReceived(data)
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1175, in _dataReceived
    self.consumeData()
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1187, in consumeData
    while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1553, in processData
    fr = self.onFrameEnd()
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 1674, in onFrameEnd
    self._onMessageEnd()
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\twisted\websocket.py", line 159, in _onMessageEnd
    self.onMessageEnd()
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\websocket\protocol.py", line 627, in onMessageEnd
    self._onMessage(payload, self.message_is_binary)
    File "C:\ProgramData\Anaconda3\lib\site-packages\autobahn\twisted\websocket.py", line 162, in _onMessage
    self.onMessage(payload, isBinary)
    File "C:\ProgramData\Anaconda3\lib\site-packages\kiteconnect-3.7.2-py3.6.egg\kiteconnect\ticker.py", line 71, in onMessage

    File "C:\ProgramData\Anaconda3\lib\site-packages\kiteconnect-3.7.2-py3.6.egg\kiteconnect\ticker.py", line 670, in _on_message

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

    builtins.OSError: [Errno 22] Invalid argument
  • girish400
    girish400 edited June 2018
    Made following changes in ticker.py
    to suppress error

    # Parse full mode
    if len(packet) == 184:
    try:
    #last_trade_time = datetime.fromtimestamp(_unpack_int(packet, 44, 48))
    if _unpack_int(packet, 44, 48) != 0:
    last_trade_time = datetime.fromtimestamp(_unpack_int(packet, 44, 48))
    else:
    last_trade_time = datetime.fromtimestamp(time.time())
    except TypeError:
    last_trade_time = None

    try:
    #timestamp = datetime.fromtimestamp(_unpack_int(packet, 60, 64))
    if _unpack_int(packet, 60, 64) != 0:
    timestamp = datetime.fromtimestamp(_unpack_int(packet, 60, 64))
    else:
    timestamp = datetime.fromtimestamp(time.time())
    except TypeError:
    timestamp = None
  • zartimus
    @girish400 Got the issue. Windows raises OSError for invalid timestamps. Can you update to 3.7.3.
  • girish400
    @zartimus Correct ! so I made the changes in code and pasted here for your reference.
  • girish400
    girish400 edited June 2018
    .
  • girish400
    @zartimus last_trade_time and timestamp should have correct value . Setting them None will cause issues or more code to handle value None. I'm not sure how feasible that is at your end or if you want the value to be None
  • zartimus
    @girish400 Fine. :) Changing TypeError to general Exception would do the trick because even datetime.fromtimestamp(1) raises the OSError so does any invalid dates.
This discussion has been closed.