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

It works but the process don't end #13

Closed
ybabel opened this issue Dec 27, 2017 · 1 comment
Closed

It works but the process don't end #13

ybabel opened this issue Dec 27, 2017 · 1 comment

Comments

@ybabel
Copy link

ybabel commented Dec 27, 2017

Hello. The script works fine, I can switch my plug on/off but, the node process doesn't quit and I get an infinite loop :

Status: true
Result of setting status to false: true
New status: false
{ Error: read ECONNRESET
    at exports._errnoException (util.js:1020:11)
    at TCP.onread (net.js:568:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at exports._errnoException (util.js:1020:11)
    at TCP.onread (net.js:568:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
[again and again]

running on ubuntu 17.10 node v6.11.4 and rasbpian node v6.12.2.
Any clue ?

Notice I also get the same problem with only a getStatus :

    const TuyaDevice = require('tuyapi');

    var tuya = new TuyaDevice({
      type: 'outlet',
      ip: '192.168.0.18',
      id: 'xxxx',
      key: 'xxxx'
    });
    tuya.getStatus(function(error, status) {
      if (error) { return console.log(error); }
      console.log('Status: ' + status);
    });

@codetheweb
Copy link
Owner

Yes, that's currently the expected behavior. To end the script, call tuya.destroy(). It currently attempts to keep the socket connected indefinitely.
However, I realize that may not be the best solution to fixing Tuya's crummy API. I'm still thinking about alternative solutions. If you have any ideas, I'm open to hearing them.

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

2 participants