WebSocket Error - Service Unavailable

Hi Team,

Today morning WebSocket is giving error when it calls on_error(error_message) in python
it displays below information; can you please check and advice

Handshake status 503 Service Unavailable -+-+- {'server': 'AkamaiGHost', 'mime-version': '1.0', 'content-length': '19', 'cache-control': 'max-age=0, no-cache, no-store', 'pragma': 'no-cache', 'expires': 'Wed, 25 Oct 2023 06:21:04 GMT', 'content-type': 'text/html', 'date': 'Wed, 25 Oct 2023 06:21:04 GMT', 'connection': 'keep-alive'} -+-+- b'Service Unavailable'

Hi @PaytmMoney

Can you please check on this

Hi @deeeepak as we are checking the issue, we request you to use reconnect feature of WebSocketClient of PMClient SDK. Please find below the link to python PMClient SDK -

You can use below sample code to create a websocket connection with reconnect feature enabled -

from pmClient.WebSocketClient import WebSocketClient

webSocketClient = WebSocketClient("your_public_access_token")

customerPreferences = []

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


def on_open():
    # send preferences via websocket once connection is open

def on_close(code, reason):
    # this event gets triggered when connection is closed
    print(code, reason)

def on_error(error_message):
    # this event gets triggered when error occurs

def on_message(arr):
    # this event gets triggered when response is received


set below reconnect config if reconnect feature is desired
Set first param as true and second param, the no. of times retry to connect to server shall be made  
webSocketClient.set_reconnect_config(True, 5)

# this method is called to create a websocket connection with broadcast server
1 Like