websocket in jupyter notebook

Jignesh
I am using python 3 from anaconda jupyter notebook
With my api key and access token i am trying to connect to websocket.

from kiteconnect import KiteTicker
kws = KiteTicker(api_key, access_token)

can we use python jupyter notebook for websocket ?
what would be the response of websocket during non market hrs. ?
Please help to solve following error


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 1675, 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

ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
  • zartimus
    zartimus edited June 2018
    @Jignesh Issue was something related to windows. Can you update the pykiteconnect to 3.7.3
  • Jignesh
    @zartimus Thanks, there seems to some issue with pykiteconnect 3.7.2. After upgrading to 3.7.3 it works fine.
This discussion has been closed.