Error - Socket is already closed (Python)

Anuj
Anuj edited November 2017 in Market data (WebSockets)
Hi,

I am getting following error while trying to connect to websockets:

ERROR:websocket:error from callback >: socket is already closed.

what am I doing wrong?

The full python code is:
from kiteconnect import WebSocket
import pandas as pd

def on_tick(tick, ws):
print(tick)

def on_connect(ws):
stocks=['ACC']
ws.subscribe(stocks)

api_key="xx" # my api kep
public_token="xx"
user_id="xxx" #my user id
#on_connect()
kws = WebSocket(api_key, public_token, user_id, reconnect=True, reconnect_interval=5, reconnect_tries=50)
#kws.on_tick = on_tick
kws.on_connect = on_connect
kws.connect()
Sign In or Register to comment.