codetheweb / tuyapi

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.
MIT License
2.1k stars 343 forks source link

Error: getaddrinfo ENOTFOUND openapi.tuyaundefined.com #496

Closed DmitryMaksakov closed 3 years ago

DmitryMaksakov commented 3 years ago

Describe the bug While trying to get device information, I am getting the Error: getaddrinfo ENOTFOUND openapi.tuyaundefined.com.

For some reason the tool tries to access openapi.tuyaundefined.com

To Reproduce `

sudo tuya-cli wizard ? The API key from tuya.com: xxxx ? The API secret from tuya.com xxxx ? Provide a 'virtual ID' of a device currently registered in the app: xxxx node:internal/process/promises:246 triggerUncaughtException(err, true / fromPromise /); ^ <ref 1> Error: getaddrinfo ENOTFOUND openapi.tuyaundefined.com at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'openapi.tuyaundefined.com', config: { url: 'https://openapi.tuyaundefined.com/v1.0/token?grant_type=1', method: 'get', headers: { Accept: 'application/json, text/plain, /*', t: '1625574613464', client_id: 'uwh3v8f4aqarkxdp5q2s', sign_method: 'HMAC-SHA256', sign: '04AD04EECB004ED5DB6C929A666A28F649C14C9F6CCF0557120B4DF62F82AA90', access_token: '', ... `

Expected behavior The tool should request correct address openapi.tuya<?>.com

Debug Output The same as in To Reproduce section

Desktop (please complete the following information):

Additional context Maybe it somehow connected to

To better secure your cloud development, Tuya will upgrade the signature algorithm. Projects created after June 30, 2021 are subject to signature verification with the new algorithm. View details. ?

tommitulpe commented 3 years ago

same issue here.

randysnel commented 3 years ago

same issue on Ubuntu

codetheweb commented 3 years ago

I am unable to reproduce this.

The wizard has been updated to use the latest signing algorithm.

Try clearing the configuration for @tuyapi/cli at ~/.config/configstore/@tuyapi/cli.json on macOS (make sure to display it beforehand in case it turns out to be relevant).

randysnel commented 3 years ago

For what its worth, I'm using Ubuntu 20.04 LTS and did a fresh instap through npm i @tuyapi/cli -g

If you spin up a new VM with Ubuntu LTS it is reproduceable for sure, just validated it myself.

root@test123:/home/test123# tuya-cli wizard ? The API key from tuya.com: xxx ? The API secret from tuya.com xxx ? Provide a 'virtual ID' of a device currently registered in the app: xxx (node:56175) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND openapi.tuyaundefined.com openapi.tuyaundefined.com:443 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26) (node:56175) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3) (node:56175) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

codetheweb commented 3 years ago

Thanks for the suggestion.

I was able to reproduce. I believe this should be fixed in v1.17.1 of @tuyapi/cli, please upgrade and let me know.

tommitulpe commented 3 years ago

Works perfectly now. Thanks a lot!

DmitryMaksakov commented 3 years ago

Works fine, thank you for the fast fix!