Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

socket timeout error #33

Closed
Minichota opened this issue Aug 13, 2018 · 15 comments
Closed

socket timeout error #33

Minichota opened this issue Aug 13, 2018 · 15 comments

Comments

@Minichota
Copy link

When trying to run the example, I get this traceback:
Traceback (most recent call last):
File "C:/Users/Minichota/PycharmProjects/Global_Automation/lights.py", line 4, in
data = d.status() # NOTE this does NOT require a valid key
File "C:\Python\lib\site-packages\pytuya_init_.py", line 255, in status
data = self.send_receive(payload)
File "C:\Python\lib\site-packages\pytuya_init
.py", line 165, in _send_receive
s.connect((self.address, self.port))
socket.timeout: timed out

I hope you can help me or guide me through to the solution

@clach04
Copy link
Owner

clach04 commented Aug 14, 2018

@Minichota is this tuyapi issue 57 - codetheweb/tuyapi#57 ? If so I'm going to hazard a guess that something has that device open already (codetheweb/tuyapi#57 (comment) indicates that maybe the phone app has it open).

This is one of those "common knowledge" things where we know the devices can only handle one active connection at a time but to know this you either need to have been burnt by this or read alot of the history comments on issues in this and the https://github.com/codetheweb/tuyapi/issues/ project (codetheweb/tuyapi#5 has a ton of information). This has sparked me to create a FAQ page in the wiki. I just need to get this into an entry there https://github.com/clach04/python-tuya/wiki/FAQ :-)

@Minichota
Copy link
Author

well, I'm quite sure that the device isn't connected to by multiple things as when the indicator light is blinking it is disconnected.

@Minichota
Copy link
Author

Minichota commented Aug 14, 2018

@clach04 I've also unplugged the device and replugged it.

@clach04
Copy link
Owner

clach04 commented Aug 14, 2018

@Minichota if the device light is blinking, then the device is not on the network. This project expect the device to already be provisioned and on the network. I'm guessing this isn't working with https://github.com/codetheweb/tuyapi/ either?

@Minichota
Copy link
Author

So are you saying that I should run it through the setup.md example you gave again? @clach04

@Minichota
Copy link
Author

Minichota commented Aug 14, 2018

I also haven't tried to use the other tuya api as I don't have a compiler for that language to my knowledge.

@clach04
Copy link
Owner

clach04 commented Aug 14, 2018

@Minichota you mean "Key extraction", yes. You'll need to provision on your network and extract the key (using your preferred method). Unfortunately it looks like the guide I linked to was updated 6 days ago to do provisioning with the CLI tool so you either need to install Node to follow the current guide or read the older guide https://github.com/codetheweb/tuyapi/blob/9c835da1139a3436f43b359b86abeb3529ae90a1/docs/SETUP.md

@Minichota
Copy link
Author

@clach04 Do you mean to do this if I wasn't able to extract the information?

@clach04
Copy link
Owner

clach04 commented Aug 14, 2018

@Minichota I don't understand the question. If the light is blinking that means its not connected to the network and its entered provisioning mode. I've updated https://github.com/clach04/python-tuya/wiki and copied the old readme.

From your description it sounds like you need to provision the device. This will change any key(s) you may have already extracted.

@Minichota
Copy link
Author

Minichota commented Aug 14, 2018

@clach04 I have connected to it using the 'old' method you posted and I have fixed the blinking light issue and its simply when I run the example you provide in the README I get a socket.timeout error as I pasted above. I have access to the all the data from the key extraction and it should technically be connected so I'm not sure.

@Minichota
Copy link
Author

@clach04 If I up the connection timeout to 50 seconds, I get this error: TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

@clach04
Copy link
Owner

clach04 commented Aug 14, 2018

@Minichota assuming the sample was updated with:

  • IP address
  • device id
  • secret key

then this suggests the machine you are running the python script is not on the same network as the wifi device. Can you ping the device?

EDIT or the phone app still has a connection open in the background.

@Minichota
Copy link
Author

Pinging 68.47.15.118 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 68.47.15.118:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

@clach04
Copy link
Owner

clach04 commented Aug 14, 2018

@Minichota so definitely a network problem. I'll close this down. If its any consolation I had a similar problem once. I was super tired 😴 and my laptop connected to an open WiFi network and I couldn't work out why I couldn't access any devices on my LAN!

@clach04 clach04 closed this as completed Aug 14, 2018
@codetheweb
Copy link

@clach04 by the way, the old setup instructions can be found here.

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

No branches or pull requests

3 participants