Websocket2.0 just stops after running for 1 min without any errors etc.
-
@admin
yes facing same , connection is getting disconnected
in first 30 sec,
Attempting to resubscribe/reconnect...
next 30 sec,
Connection closed
Connection closed
Connection closed -
Watch the video and download the code to get the live data into Excel
Youtube Video -
@projectSB i have been getting same problem. but i got the solution. go to your on
smartWebscketV2.py and find this " def on_close(self, wsapp):
pass
" on your side the argument would be 4 in there make it like this. and thats it. it will work -
@projectSB see if this helps, I've added below code when I got a similar error
def on_data(wsapp, message): if message != b'\x00': #process data
-
@ajileshparolla Nope! no solutions so far :-(
no admins replied as well -
@projectSB Did you find any solution for this? I am having the same issue.
-
@af I'm using the Websocket version 2.0 code as provided in this Github link:
https://github.com/angel-one/smartapi-python
This portion:
####### Websocket V2 sample code #######
from SmartApi.smartWebSocketV2 import SmartWebSocketV2
from logzero import loggerAUTH_TOKEN = "Your Auth_Token"
API_KEY = "Your Api_Key"
CLIENT_CODE = "Your Client Code"
FEED_TOKEN = "Your Feed_Token"
correlation_id = "abc123"
action = 1
mode = 1
token_list = [
{
"exchangeType": 1,
"tokens": ["26009"]
}
]
sws = SmartWebSocketV2(AUTH_TOKEN, API_KEY, CLIENT_CODE, FEED_TOKEN)def on_data(wsapp, message):
logger.info("Ticks: {}".format(message))
# close_connection()def on_open(wsapp):
logger.info("on open")
sws.subscribe(correlation_id, mode, token_list)def on_error(wsapp, error):
logger.error(error)def on_close(wsapp):
logger.info("Close")def close_connection():
sws.close_connection()Assign the callbacks.
sws.on_open = on_open
sws.on_data = on_data
sws.on_error = on_error
sws.on_close = on_closesws.connect()
-
@projectSB can you share the code i am not able to find the exact version
-
@nagabhushant Well, I'm using WebSocket 2.0 from inside the Python SDK, as per the guidelines provided in the Github page.
-
Hi,
Are you using ws://smartapisocket.angelone.in/smart-stream for websocket 2.0 connection?