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

Slow api, ETIMEDOUT, ECONRESET, ECONNREFUSED #208

Open
Mr-KoKa opened this issue Feb 26, 2023 · 14 comments
Open

Slow api, ETIMEDOUT, ECONRESET, ECONNREFUSED #208

Mr-KoKa opened this issue Feb 26, 2023 · 14 comments

Comments

@Mr-KoKa
Copy link

Mr-KoKa commented Feb 26, 2023

const ewelink = require('ewelink-api');

(async () => {
  let start = Date.now();
  const connection = new ewelink({
    email: '...',
    password: '...',
    region: 'eu',
  });
  console.log('connection', (Date.now() - start) / 1000);

  try {
    /* get all devices */
    start = Date.now();
    const devices = await connection.getDevices();
    console.log('devices', (Date.now() - start) / 1000);

    /* get specific devide info */
    start = Date.now();
    const device = await connection.getDevice('...');
    console.log('device', (Date.now() - start) / 1000);

    console.log('end');
  } catch(e){
    console.log('exception', (Date.now() - start) / 1000);
    console.log(e);
  }
})();

Above code results in wide range of connection errors:

\...\_ewelink-test>node test.js
connection 0

\...\_ewelink-test\node_modules\node-fetch\lib\index.js:1505
                        reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
                               ^
FetchError: request to https://eu-api.coolkit.cc:8080/api/user/login failed, reason: connect ECONNREFUSED 52.57.118.192:8080
    at ClientRequest.<anonymous> (\...\_ewelink-test\node_modules\node-fetch\lib\index.js:1505:11)
    at ClientRequest.emit (node:events:527:28)
    at TLSSocket.socketErrorListener (node:_http_client:454:9)
    at TLSSocket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED'
}

\...\_ewelink-test>node test.js
connection 1

\...\_ewelink-test\node_modules\node-fetch\lib\index.js:1505
                        reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
                               ^
FetchError: request to https://eu-api.coolkit.cc:8080/api/user/device?lang=en&appid=...&ts=1677441318&version=8&getTags=1 failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (\...\_ewelink-test\node_modules\node-fetch\lib\index.js:1505:11)
    at ClientRequest.emit (node:events:527:28)
    at TLSSocket.socketErrorListener (node:_http_client:454:9)
    at TLSSocket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}

\...\_ewelink-test>node test.js
connection 0
exception 17.593
FetchError: request to https://eu-api.coolkit.cc:8080/api/user/login failed, reason: connect ECONNREFUSED 52.57.118.192:8080
    at ClientRequest.<anonymous> (\...\_ewelink-test\node_modules\node-fetch\lib\index.js:1505:11)
    at ClientRequest.emit (node:events:527:28)
    at TLSSocket.socketErrorListener (node:_http_client:454:9)
    at TLSSocket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED'
}

\...\_ewelink-test>node test.js
connection 0
exception 68.915
FetchError: request to https://eu-api.coolkit.cc:8080/api/user/login failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (\...\_ewelink-test\node_modules\node-fetch\lib\index.js:1505:11)
    at ClientRequest.emit (node:events:527:28)
    at TLSSocket.socketErrorListener (node:_http_client:454:9)
    at TLSSocket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}

\...\_ewelink-test>node test.js
connection 0
exception 168.683
FetchError: request to https://eu-api.coolkit.cc:8080/api/user/login failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (\...\_ewelink-test\node_modules\node-fetch\lib\index.js:1505:11)
    at ClientRequest.emit (node:events:527:28)
    at TLSSocket.socketErrorListener (node:_http_client:454:9)
    at TLSSocket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}

Pinging the IP of the endpoint works.

Running the same code on linux server does work most of the time but the times of execution are unacceptable:

# node test.js
connection 0
devices 28.744
device 11.362
end
# node test.js
connection 0
devices 88.173
device 13.592
end
# node test.js
connection 0.001
exception 172.009
FetchError: request to https://eu-api.coolkit.cc:8080/api/user/device?lang=en&appid=...&ts=1677442551&version=8&getTags=1 failed, reason: connect ETIMEDOUT 52.57.118.192:8080
    at ClientRequest.<anonymous> (/root/_/ewelink-test/node_modules/node-fetch/lib/index.js:1505:11)
    at ClientRequest.emit (node:events:378:20)
    at TLSSocket.socketErrorListener (node:_http_client:462:9)
    at TLSSocket.emit (node:events:378:20)
    at emitErrorNT (node:internal/streams/destroy:188:8)
    at emitErrorCloseNT (node:internal/streams/destroy:153:3)
    at processTicksAndRejections (node:internal/process/task_queues:81:21) {
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT'
}

It was working good before, it started to malfunction about 2 days ago so ~ 2023-02-24

@Aristomastrosi
Copy link

Aristomastrosi commented Feb 26, 2023

Same here. Stopped working 1-2 days ago. If anyone has a clue how to fix it it would be great. In the meanwhile you can consider switching to webhooks. A little bit cumbersome to setup with ewelink web (scenes) but works until there is a bugfix, unless you need to read out states.

@evikhorev
Copy link

Same problem!

@javcz
Copy link

javcz commented Feb 27, 2023

Same issue (not a surprise ... the same enpoint). What is a kind of surprise - the websocket callbacks work still well.

@apadilla83
Copy link

Same Problem, where I can report this issued=?

@paliuca
Copy link

paliuca commented Feb 27, 2023

Same problem here :(

@pebs74
Copy link

pebs74 commented Feb 27, 2023

Seems like https://eu-api.coolkit.cc:8080 is not responding (or very inconsistently).

The 'us' server is responding, but cannot be used with EU ewelink accounts...

@pj-est
Copy link

pj-est commented Feb 27, 2023

There are talks on the eWeLink Telegram group about how their server may have been overloaded, maybe an accidental DDoS through someone's bad code, who knows. I can get a login every now and then, but then as soon as you try do anything it seems the authentication is now broken as well. So I keep getting a { error: 406, msg: 'Authentication failed' } response using this package, the Postman response below shows it's not accepting the Bearer token anymore.

Screenshot 2023-02-27 154039

@javcz
Copy link

javcz commented Feb 27, 2023

I also believe the accidental DoS is a likely explanation. That answers why the websocket interface still works well ... without any delay. Btw the status of the "main" control API is not consistent, a while ago it worked well. At this moment it still works but slow (~20 sec delay).

@pj-est
Copy link

pj-est commented Feb 27, 2023

Interestingly the mobile app and web portal are triggering my relays instantly. Apparently the API this package uses is not officially supported by eWeLink, so I don't think we can count on a quick resolution from them here. Busy fishing around the web portal to see if there's anything I can grab onto there.

@pj-est
Copy link

pj-est commented Feb 27, 2023

FYI https://coolkit-technologies.github.io/eWeLink-API/#/en/PlatformOverview

@bartoszpijet
Copy link

Has anyone tested branch 4.0.0 already? IDK if it's worth spending time testing it

@tarres
Copy link

tarres commented Feb 27, 2023

Has anyone tested branch 4.0.0 already? IDK if it's worth spending time testing it

It's not an issue of this library, its a problem on eweLink's server, so you can't fix it by changing to any version of this library here.

Hopefully it will be back soon. The https://eu-api.coolkit.cc:8080 response went from 503 to the OpenResty default page already, so they are working on it.

@bartoszpijet
Copy link

Has anyone tested branch 4.0.0 already? IDK if it's worth spending time testing it

It's not an issue of this library, its a problem on eweLink's server, so you can't fix it by changing to any version of this library here.

Hopefully it will be back soon. The https://eu-api.coolkit.cc:8080 response went from 503 to the OpenResty default page already, so they are working on it.

Just noticed that this branch changes API addresses and uses V2, maybe it uses different routes on load balancers and works, just didn't have time to test it

@apadilla83
Copy link

I just testing th api now, and its works fine without delay, seems solved now!!!. 3 days to solved this, is too much.... There are other way to control ewelink devices? Sonoff zero in lan does not work correctly in certain situations with 2 canal devices.. there is some documentation to work with the devices on lan? without this api?

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

No branches or pull requests

10 participants