Closed anrolmar closed 4 years ago
The connection timeout error is due to TuyAPI not being able to connect to the device.
Make sure the IP is correct and pingable from wherever you're running the script.
(Also, are you running it in Docker? There might be something weird going on with Docker's networking.)
Hi, @codetheweb.
I try to this:
ping 192.168.100.120 PING 192.168.100.120 (192.168.100.120) 56(84) bytes of data. From 192.168.100.201 icmp_seq=1 Destination Host Unreachable From 192.168.100.201 icmp_seq=2 Destination Host Unreachable
Why does the ping jump to 192.168.100.201? This is my local IP from the server.
I can't say why the ping isn't working, but that's why TuyAPI isn't working.
What's your network setup like?
When I exec this command:
tuya-cli get --id
events.js:174 throw er; // Unhandled 'error' event ^ Error: Error from socket at Socket.client.on.err (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:323:30) at Socket.emit (events.js:189:13) at emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) at process._tickCallback (internal/process/next_tick.js:63:19) Emitted 'error' event at: at Socket.client.on.err (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:323:16) at Socket.emit (events.js:189:13) [... lines matching original stack trace ...] at process._tickCallback (internal/process/next_tick.js:63:19)
My device is strip plug ( https://ru.aliexpress.com/item/32956103278.html?spm=a2g0s.9042311.0.0.274233edH8WnuK)
Strip plug is working from Smart Life App, but I want it include into OpenHAB
@alex-par does ping 192.168.1.5
run successfully from the same computer you're trying to control it from?
@codetheweb @alex-par I get the same of you. When I try tuya-cli get --id --key --ip 192.168.100.120 --all, I get the message:
Error: connection timed out at Socket.client.setTimeout (/root/.nvm/versions/node/v8.12.0/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:292:18) at Object.onceWrapper (events.js:313:30) at emitNone (events.js:106:13) at Socket.emit (events.js:208:7) at Socket._onTimeout (net.js:422:8) at ontimeout (timers.js:498:11) at tryOnTimeout (timers.js:323:5) at Timer.listOnTimeout (timers.js:290:5)
@anrolmar it looks like you're passing the --id
flag but never actually provide an ID value. You'll need to add in the ID of your device or you can try removing that flag.
Sorry. In fact, I use tuya-cli get --id XXXXX --key YYYYY --ip 192.168.100.120 --all. And the same message
@anrolmar sorry, didn't remember the rest of the context when posting my last message.
If you can't successfully ping your device, TuyAPI will not be able to control it. I can't help you more without some more details about your network setup.
@anrolmar I can do ping successfully.
@alex-par does
ping 192.168.1.5
run successfully from the same computer you're trying to control it from?
Sorry! Sorry, please. ( I sent the wrong screenshot. this one should be:
tuya-cli get --id xxxxx --key xxxx --ip 192.168.1.14 --all
(node:4994) UnhandledPromiseRejectionWarning: Error: Error from socket
at Socket.client.on.err (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:323:30)
at Socket.emit (events.js:189:13)
at onwriteError (_stream_writable.js:425:12)
at onwrite (_stream_writable.js:456:5)
at doWrite (_stream_writable.js:406:11)
at writeOrBuffer (_stream_writable.js:394:5)
at Socket.Writable.write (_stream_writable.js:294:11)
at Promise (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:232:23)
at new Promise (
But now this command( tuya-cli get --id xxxxx --key xxxx --ip 192.168.1.14 --all) does not give any answer, just hanging in wait lot minutes
ping 192.168.1.14 PING 192.168.1.14 (192.168.1.14) 56(84) bytes of data. 64 bytes from 192.168.1.14: icmp_seq=1 ttl=255 time=148 ms
Sorry! I found an error, the protocol should be 3.3 ( --protocol-version 3.3)
@anrolmar does TuyAPI give you the same error now that pinging the device is working?
@codetheweb Hi. My device is pingable, but the it is that state, the console is: TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 192.168.100.120... +2ms TuyAPI Error event from socket. 192.168.100.120 { Error: connect ECONNREFUSED 192.168.100.120:6668 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14) errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '192.168.100.120', port: 6668 } +57ms events.js:183 throw er; // Unhandled 'error' event ^
Error: Error from socket at Socket.client.on.err (/root/.nvm/versions/node/v8.12.0/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:323:30) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:66:8) at _combinedTickCallback (internal/process/next_tick.js:139:11) at process._tickCallback (internal/process/next_tick.js:181:9)
Do I need to open the port 6668 in the device? In that case, how can I open it?
Have you tried adding --protocol-version 3.3
to the argument list?
Yes, I've tried with it and the same error.
I've reviewed the ports and I've seen that the port 6668 is closed. Could it be the error? How can I open this port?
What are you using to see if the port is open?
If you use Nmap you should get a result similar to this.
Hi.
I use this:
As you see, the port 6668 is closed
Hmm, it may only communicate with the cloud and not have local control enabled (although I haven't heard of a device yet that does that).
Do you have a link to the product page?
Ah, I'm sorry for not asking if it was a sensor sooner.
TuyAPI does not support sensors due to the fact that they only connect to the network when their state changes. There are no plans to add support as it's out of scope to intercept network requests.
I've had a couple issues come up related to sensors so I'll add a section about them to the TuyAPI readme.
Thanks, @codetheweb
Thanks @codetheweb I looked up my version in the app, which displayed 3.1.1 to me. I tried setting it then to 3.3 in the CLI even though it should be 3.1 and it worked.
Hi, @codetheweb.
I have a device configured correctly in my Tuya App.
But when I try to use tuya-cli for connect with it, I get the next message:
DEBUG=* tuya-cli get --ip 192.168.100.120 --id xxxxxxxxx --key yyyyyyyyy --all TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 192.168.100.120... +3ms Error: connection timed out at Socket.client.setTimeout (/root/.nvm/versions/node/v8.12.0/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:292:18) at Object.onceWrapper (events.js:313:30) at emitNone (events.js:106:13) at Socket.emit (events.js:208:7) at Socket._onTimeout (net.js:422:8) at ontimeout (timers.js:498:11) at tryOnTimeout (timers.js:323:5) at Timer.listOnTimeout (timers.js:290:5) TuyAPI Socket closed: 192.168.100.120 +5s
Can you give some hints?
Regards