kws unsubscribe throws exception

chaklin
'__version__': '3.9.0'
pykiteconnect
below is t6he stack trace. please help.

Traceback (most recent call last):
File "/home/udir/envs/py36/lib/python3.6/site-packages/kiteconnect/ticker.py", line 589, in unsubscribe
six.b(json.dumps({"a": self._message_unsubscribe, "v": instrument_tokens}))
File "/home/udir/envs/py36/lib/python3.6/site-packages/autobahn/websocket/protocol.py", line 2273, in sendMessage
self.sendFrame(opcode=opcode, payload=payload, sync=sync, rsv=4 if sendCompressed else 0)
File "/home/udir/envs/py36/lib/python3.6/site-packages/autobahn/websocket/protocol.py", line 1867, in sendFrame
self.sendData(raw, sync, chopsize)
File "/home/udir/envs/py36/lib/python3.6/site-packages/autobahn/websocket/protocol.py", line 1330, in sendData
self.transport.write(data)
File "/home/udir/envs/py36/lib/python3.6/site-packages/twisted/protocols/tls.py", line 467, in write
self._write(bytes)
File "/home/udir/envs/py36/lib/python3.6/site-packages/twisted/protocols/tls.py", line 547, in _write
self._flushSendBIO()
File "/home/udir/envs/py36/lib/python3.6/site-packages/twisted/protocols/tls.py", line 257, in _flushSendBIO
self.transport.write(bytes)
File "/home/udir/envs/py36/lib/python3.6/site-packages/twisted/internet/_newtls.py", line 191, in write
FileDescriptor.write(self, bytes)
File "/home/udir/envs/py36/lib/python3.6/site-packages/twisted/internet/abstract.py", line 356, in write
self.startWriting()
File "/home/udir/envs/py36/lib/python3.6/site-packages/twisted/internet/abstract.py", line 443, in startWriting
self.reactor.addWriter(self)
File "/home/udir/envs/py36/lib/python3.6/site-packages/twisted/internet/epollreactor.py", line 127, in addWriter
EPOLLOUT, EPOLLIN)
File "/home/udir/envs/py36/lib/python3.6/site-packages/twisted/internet/epollreactor.py", line 94, in _add
self._poller.modify(fd, flags)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "myticker.py", line 130, in kwsDisconnect
kws.unsubscribe(instrument_tokens)
File "/home/udir/envs/py36/lib/python3.6/site-packages/kiteconnect/ticker.py", line 600, in unsubscribe
self._close(reason="Error while unsubscribe: {}".format(str(e)))
File "/home/udir/envs/py36/lib/python3.6/site-packages/kiteconnect/ticker.py", line 544, in _close
self.ws.sendClose(code, reason)
File "/home/udir/envs/py36/lib/python3.6/site-packages/autobahn/websocket/protocol.py", line 2001, in sendClose
raise Exception("close reason without close code")
Exception: close reason without close code
  • rakeshr
    rakeshr edited March 2021
    kws.unsubscribe(instrument_tokens)
    You need to use ws.unsubscribe(tokens) to unsubscribe required token/list of tokens.
  • chaklin
    @rakeshr i am not unsubscribing inside a callback if that is what you are referring to . but in a separate function which is being called by another py importing 'myticker'
  • rakeshr
    @chaklin
    You need to paste the WebSocket code, for us to debug this further. From the above stack trace, it looks like you are not calling unsubscribe method properly.
Sign In or Register to comment.