Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eufy API is returning 204 errors causing the library to fail #67

Closed
SerialVelocity opened this issue Nov 18, 2021 · 5 comments
Closed
Assignees
Labels

Comments

@SerialVelocity
Copy link

Describe the bug
Calls seem to be randomly failing and returning 204 errors

To Reproduce
Steps to reproduce the behavior:

  1. Use code:
     const eufy: EufySecurity = new EufySecurity(config, logger);
     if (!await eufy.connect()) {
         console.log("Couldn't connect");
     }
    
     await eufy.refreshCloudData();
    
  2. View logs

Expected behavior
Calls to not fail.

Screenshots & Logfiles
If applicable, add screenshots and logfiles to help explain your problem.
Without debug logging:

> tsc -p .

2021-11-18 23:15:33.860  ERROR Status return code not 200
{
  status: 204,
  statusText: 'No Content'
}
2021-11-18 23:15:34.391  ERROR Station <REDACTED> - Status return code not 200
{
  status: 204,
  statusText: 'No Content'
}

With debug logging:

2021-11-18 23:31:17.342  DEBUG [HTTPApi.request] Request:
{
  method: 'post',
  endpoint: 'app/get_hub_list',
  baseUrl: 'https://security-app-eu.eufylife.com/v1',
  token: '<REDACTED>',
  data: undefined,
  headers: {
    app_version: 'v2.8.0_887',
    os_type: 'android',
    os_version: '30',
    phone_model: 'EUFYCLIENT',
    country: 'GB',
    language: 'en',
    openudid: '<REDACTED>',
    uid: '',
    net_type: 'wifi',
    mnc: '02',
    mcc: '262',
    sn: '<REDACTED>',
    Model_type: 'PHONE',
    timezone: 'GMT+00:00'
  }
}
2021-11-18 23:31:17.498  DEBUG [HTTPApi.updateDeviceInfo] Stations - Response:
2021-11-18 23:31:17.498  ERROR [HTTPApi.updateDeviceInfo] Status return code not 200
{
  status: 204,
  statusText: 'No Content'
}

Versions:

  • Client version: 1.2.4
  • Node version: v14.18.1
  • Operating system: OSX 10.15.7

Additional context
The calls don't always fail. For example, two calls right after each other:

2021-11-18 21:11:52.841  DEBUG [HTTPApi.request] Request:
{
  method: 'post',
  endpoint: 'app/cipher/get_ciphers',
  baseUrl: 'https://security-app-eu.eufylife.com/v1',
  token: '<REDACTED>',
  data: {
    cipher_ids: [
      16
    ],
    user_id: '<REDACTED>',
    transaction: '1637269912840'
  },
  headers: {
    app_version: 'v2.8.0_887',
    os_type: 'android',
    os_version: '30',
    phone_model: 'EUFYCLIENT',
    country: 'GB',
    language: 'en',
    openudid: '<REDACTED>',
    uid: '',
    net_type: 'wifi',
    mnc: '02',
    mcc: '262',
    sn: '<REDACTED>',
    Model_type: 'PHONE',
    timezone: 'GMT+00:00'
  }
}
2021-11-18 21:11:52.986  DEBUG [HTTPApi.getCiphers] Response:
{
  code: 0,
  msg: 'Succeed.',
  data: [
    {
      cipher_id: 16,
      user_id: '<REDACTED>',
      private_key: '-----BEGIN RSA PRIVATE KEY-----\n' +
        '<REDACTED>' +
        '-----END RSA PRIVATE KEY-----\n'
    }
  ]
}
2021-11-18 21:11:52.987  DEBUG [HTTPApi.request] Request:
{
  method: 'post',
  endpoint: 'app/cipher/get_ciphers',
  baseUrl: 'https://security-app-eu.eufylife.com/v1',
  token: '<REDACTED>',
  data: {
    cipher_ids: [
      16
    ],
    user_id: '<REDACTED>',
    transaction: '1637269912987'
  },
  headers: {
    app_version: 'v2.8.0_887',
    os_type: 'android',
    os_version: '30',
    phone_model: 'EUFYCLIENT',
    country: 'GB',
    language: 'en',
    openudid: '<REDACTED>',
    uid: '',
    net_type: 'wifi',
    mnc: '02',
    mcc: '262',
    sn: '<REDACTED>',
    Model_type: 'PHONE',
    timezone: 'GMT+00:00'
  }
}
2021-11-18 21:11:53.106  DEBUG [HTTPApi.getCiphers] Response:
2021-11-18 21:11:53.106  ERROR [HTTPApi.getCiphers] Status return code not 200
{
  status: 204,
  statusText: 'No Content'
}
@Malnes
Copy link

Malnes commented Nov 20, 2021

I believe the EU endpoint (ot at least the one for norway) is wrong.

This is just a guess as I don't know what I'm doing, but it seems like it tries to retrieve the token from https://security-app-eu.eufylife.com/v1. I am able to retrieve token when using this endpoint: https://mysecurity.eufylife.com/api/v1/passport/login

I have the following error:

2021-11-19 23:02:52.162 INFO Authentication properties changed, invalidate saved cloud token.
2021-11-19 23:02:52.218 INFO Eufy Security server listening on port 3000
2021-11-19 23:02:53.443 INFO Switching to another API_BASE (https://security-app-eu.eufylife.com/v1) and get new token.
2021-11-19 23:02:53.644 ERROR Status return code not 200
{
status: 204,
statusText: 'No Content'
}
2021-11-19 23:02:53.658 ERROR Token error

@bropat
Copy link
Owner

bropat commented Nov 20, 2021

Eufy has made some changes to its site, which now often results in HTTP errors (204).
I have seen that the entry endpoint in the Eufy app has changed.
I am trying to understand what has changed and how to get everything working again.

That is the disadvantage of no open API... :(

@danstreeter
Copy link

danstreeter commented Nov 20, 2021

Anything I can do to help @bropat.

I'm a software engineer (however no experience in typescript) but happy to help if I can.

Let me know if there are any mitm tests I can run as I'm UK based so will get an EU API endpoint.

Hillariously just bought the Eufy2k Wireless Doorbell with hopes/guides on getting it setup in Home Assistant, so keen to get it working! =)

@bropat
Copy link
Owner

bropat commented Nov 20, 2021

@danstreeter
Thank you for the offer, but I think I have solved the problem.
I am currently testing the solution.
It looks like Eufy is now using HTTP/2 and the library I used does not support it yet.

@danstreeter
Copy link

Ah awesome nice one.
Let me know if you need any testing doing.
I’m running docker so presumably if I can build the image locally I can test that way if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants