Reconnecting with Web Socket

I am using PmClient web socket to get pre-defined instruments live data. How to re-connect with web socket to modify / update instruments list t o get live data with updated list.

Hi @satyamtd, modify the preference list that you are subscribing via websocket and then re run the program. Your updated list will be subscribed and you will be receiving the live data of updated list.

Find an example code in python below -

customerPreferences = []

preference1 = {
    "actionType": 'ADD',  # 'ADD', 'REMOVE'
    "modeType": 'LTP',  # 'LTP', 'FULL', 'QUOTE'
    "scripType": 'INDEX',  # 'ETF', 'FUTURE', 'INDEX', 'OPTION', 'EQUITY'
    "exchangeType": 'NSE',  # 'BSE', 'NSE'
    "scripId": '13'


preference2 = {
    "actionType": 'ADD',  # 'ADD', 'REMOVE'
    "modeType": 'FULL',  # 'LTP', 'FULL', 'QUOTE'
    "scripType": 'EQUITY',  # 'ETF', 'FUTURE', 'INDEX', 'OPTION', 'EQUITY'
    "exchangeType": 'NSE',  # 'BSE', 'NSE'
    "scripId": '3456'


Without restarting the program I need to append preferences.

Hi @satyamtd, when you create an object of WebSocketClient class using below code
webSocketClient = WebSocketClient("your_public_access_token")
this object can be used to call the subscribe method present in WebSocketClient class that takes your preference list and sends it to broadcast server for subscription.
So, what you need to do is create an updated list of preferences and pass on this list to subscribe method


For more details regarding preference structure, refer below link (under preference structure section) -