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'
}
customerPreferences.append(preference)
def on_open():
# send preferences via websocket once connection is open
webSocketClient.subscribe(customerPreferences)
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
print(error_message)
def on_message(arr):
# this event gets triggered when response is received
print(arr)
webSocketClient.set_on_open_listener(on_open)
webSocketClient.set_on_close_listener(on_close)
webSocketClient.set_on_error_listener(on_error)
webSocketClient.set_on_message_listener(on_message)
"""
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
webSocketClient.connect()
I am facing same issue–Received Error- Handshake status 503 Service Unavailable -±± {‘content-type’: ‘text/html; charset=utf-8’, ‘content-length’: ‘6337’, ‘x-robots-tag’: ‘noindex’, ‘expires’: ‘Tue, 15 Oct 2024 05:22:02 GMT’, ‘cache-control’: ‘max-age=0, no-cache, no-store’, ‘pragma’: ‘no-cache’, ‘date’: ‘Tue, 15 Oct 2024 05:22:02 GMT’, ‘connection’: ‘keep-alive’}
reconnect is not working in my case please help to check the issue.
Date: 16 October 2024: @eryan : is it working for you?, it not working for me and there is no response from paytm technical team on this issue
Date: 15th Ocotober 2024
now I am able to connect for brief moment , but it’s getting closed immediately with error ( Connection Closed: CloseReason[1006,Closed abnormally.]
Date : 16th Oct 2024 time 10:24 AM
same issue still persist (org.glassfish.tyrus.client.RetryAfterException: HTTP Status code 503 - Service Unavailable.) ,
@eryan : is it working for you? , mine is not working , let’s connect my gmaaail id is sktonger2 , thanks
Date: 15th October 2024, time: 11: 00 AM
Again getting below excpetionjavax.websocket.DeploymentException: Handshake error.org.glassfish.tyrus.client.RetryAfterException: HTTP Status code 503 - Service Unavailable.stackTrace = {StackTraceElement[13]@5782}
0 = {StackTraceElement@5784} “org.glassfish.tyrus.client.ClientManager$3$1.run(ClientManager.java:636)”
1 = {StackTraceElement@5785} “org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:673)”
2 = {StackTraceElement@5786} “java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)”
3 = {StackTraceElement@5787} “java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)”
4 = {StackTraceElement@5788} “java.base/java.util.concurrent.FutureTask.run(FutureTask.java)”
5 = {StackTraceElement@5789}
Thank You @Peter for resolving this issue. Much appreciated.
As suggested, we will raise issues on openapi.care@paytmmoney.com if faced prolems again, hope it never arise.
Long live PaytmMoney.