I keep getting disconnected from the WebSocket server due to login failures, and I need a solution to automatically reconnect and retry the login when this happens to maintain a stable connection. Have anyone experienced this before?
For a deeper look into our Elektron API, look into:
Overview | Quickstart | Documentation | Downloads | Tutorials | Articles
I keep getting disconnected from the WebSocket server due to login failures, and I need a solution to automatically reconnect and retry the login when this happens to maintain a stable connection. Have anyone experienced this before?
Hi @AmeliaCatherine ,
Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?
If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.
Thanks,
AHS
Hi,
Please be informed that a reply has been verified as correct in answering the question, and marked as such.
Thanks,
AHS
Hello @AmeliaCatherine
### Reconnection ###
There is the reconnection logic example available on the market_price_rdpgw_service_discovery.py example as follows:
def _on_close(self, ws, close_status_code, close_msg): """ Called when websocket is closed """ self.web_socket_open = False self.logged_in = False print("WebSocket Closed for " + self.session_name) if not self.disconnected: print("Reconnect to the endpoint for " + self.session_name + " after 3 seconds... ") time.sleep(3) self.connect()
However, the example is for illustrative purposes only, as mentioned in the disclaimer.
#!/usr/bin/env python # |----------------------------------------------------------------------------- # | This source code is provided under the Apache 2.0 license -- # | and is provided AS IS with no warranty or guarantee of fit for purpose. -- # | See the project's LICENSE.md for details. -- # | Copyright (C) 2018-2021 Refinitiv. All rights reserved. -- # |-----------------------------------------------------------------------------
### login failures ###
Can you give me more detail about the login failures issue?