"Exception while retriving IP Address,using local host IP address" causing performance issues.


  • I am using python smart api to connect with my trading account and execute the trades.
    My code is deployed in AWS and I am using AWS Lambda functions for executing the API calls through the smart API python library.
    For some of the requests, it is taking a very long time [more than 6 minutes], when I debugged the issue the below code is causing the delay. Based on the below code I don't see the need of getting the clientPublicIP and clientLocalIp as at the finally block we are overwriting these values. Can u please check and get rid of this un necessary code which is causing delays in executing the critical APIs.
    Call me at 9885577812 to discuss further on this issue?
    try:
    clientPublicIp= " " + get('https://api.ipify.org').text
    if " " in clientPublicIp:
    clientPublicIp=clientPublicIp.replace(" ","")
    hostname = socket.gethostname()
    clientLocalIp=socket.gethostbyname(hostname)
    except Exception as e:
    print("Exception while retriving IP Address,using local host IP address",e)
    finally:
    clientPublicIp="106.193.147.98"
    clientLocalIp="127.0.0.1"


  • @admin @Ashok Can u please help me how to modify the python code and commit the changes back?


  • @ravitandur You can comment the api call for the public IP. I have done it and have no impact on the functionality.

    DM me if you have any more questions.


  • Hi @ravitandur

    We have tried using the SDKs and did not experience any lag in order execution, , it is possible that the issue is specific to your setup or usage of the SDKs. It is always a good idea to seek help from the SmartAPI community here.


  • @admin if I want to modify python code what is the process. I want to remove above code mentioned and commit the changes into git repo. Please suggest what needs to be done?


  • a4e55632-766d-435d-b497-df9ad8fece0c-image.png

    In the above, request is initiated at 15:18 and we see the Exception at 15:24 and based on the debugging it is taking time in the code mentioned above which is not required.