Connection Error while login.


  • Im getting the below error while trying to login.

    ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

    This is the code. Its working sometimes and sometimes not.

    def create_session(angel_one_details):
        headers = {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'X-UserType': 'USER',
            'X-SourceID': 'WEB',
            'X-PrivateKey': angel_one_details['api_key'],
            'X-ClientLocalIP': "127.0.0.1",
            'X-ClientPublicIP': "106.193.147.98",
            'X-MACAddress': ':'.join(re.findall('..', '%012x' % uuid.getnode())),
        }
        totp = pyotp.TOTP(angel_one_details['totp'])
        payload = {
            'clientcode': angel_one_details['id'],
            'password': angel_one_details['pin'],
            'totp': str(totp.now())
        }
        r = requests.post(ANGEL_ONE_LOGIN_URL, data=json.dumps(payload), headers=headers)
        print("Angle one login response : {}".format(r.text))
        if r.status_code != 200:
            raise errors.CustomError("Angle one login Failed {}".format(r.text))
        return r.json()
    

  • @Phanilbb said in Connection Error while login.:

    angel

    Write a clean code
    If errors.CustomError is a custom class, import it from its module.
    also, Validate the JSON response structure.
    Correct "Angle" to "Angel" in the error message


  • same issue


  • @Phanilbb same with me.

    ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

    Don't know what happen.
    @admin123