Saving Response Not Working

Hi, I am using fyers_apiv3 and I am trying to save the response from Websocket to the log file, but I am getting empty file all the time. I have tried with turning ‘write_to_file = True’ but is isn’t working. Any suggestions to save the responses?

I am providing a screenshot for reference. Thanks!

Hey @105254772856376875797

Please refer to the docs for this the write_to_file process is mentioned

https://myapi.fyers.in/docsv3#tag/Web-Socket/paths/~1GeneralSocket/head

Hi @WWhYB2qrsx

I have referred to the document, but still the log file is empty. Any suggestions for the debugging itself?

From your program, do a test write to same file and check if its actually working.

Use absolute path and test.

Hi Chirag, so the file is being created correctly. But when it comes to saving in the file, nothing is happening.

So like here, the other log is working fine but when it comes to data log it ain’t working

Hii @105254772856376875797 .

I found a solution to it,

fyers = data_ws.FyersDataSocket(
    access_token=access_token,       # Access token in the format "appid:accesstoken"
    log_path="",                     # Path to save logs. Leave empty to auto-create logs in the current directory.
    litemode=True,                  # Lite mode disabled. Set to True if you want a lite response.
    write_to_file=True,              # Save response in a log file instead of printing it.
    reconnect=True,                  # Enable auto-reconnection to WebSocket on disconnection.
    on_connect=onopen,               # Callback function to subscribe to data upon connection.
    on_close=onclose,                # Callback function to handle WebSocket connection close events.
    on_error=onerror,                # Callback function to handle WebSocket errors.
    # on_message=onmessage             # Callback function to handle incoming messages from the WebSocket.
)

just remove or comment the on_message line, then it will be logged in debug file

Hi @100829486379533307853,

Thanks! It worked finally.