fananimi / pyzk

Unofficial library of zkteco fingerprint attendance machine
GNU General Public License v2.0
498 stars 330 forks source link

Timeout error #150

Closed jvguerrero closed 1 year ago

jvguerrero commented 2 years ago

Hi sir, i hope can you help me. I'm triying to conect a device with tcp procotol but during the process terminate itself with timeout error

I track the error in base.py file and it has produced in self.tcp_data_recv = self.sock.recv(response_size + 8)

The device is ZMM200_TFT

jvguerrero commented 2 years ago

image

kurenai-ryu commented 2 years ago

timeout means that the device didn't answer to the tcp command.

  1. confirm a device response (ping)
  2. test with zkteco software (capture wireshark pcap file)
  3. disable communication password
  4. test with UDP communication
  5. try with another library (pyzatt)

reopen if you have more information (pcap file to analize, maybe it uses different commands)

jvguerrero commented 2 years ago

Sir, the ping its okay and i've tried udp connection but it fail too

I attached 2 files, the zksoftware.zip is the trace using zk software with succesful connection and the pythonlib.zip is the timeout error.

There is the config i've used image

zk software.zip pythonlib.zip

kurenai-ryu commented 2 years ago

ok, what I see from your zk software PCAP is that the connect command has 2 extra bytes, 0x6c 0x00, I haven't found this behavior before, but anyway, I made a test branch, (MR ) which you can use to test with a connection line like:

conn = zk.connect(b'\x6c\x00')

also don't forget that there's a comm password, so don't forget to add a password to the Instantiation line ZK('192.168.70.35', port=4370, password='YOURPASSCODE')

kurenai-ryu commented 2 years ago

ok, after further checking, it seems it sends a lot of times that 0x6c 0x00 so please check by adding the b'\x6c\x00' in connect is enough or it's needed in other 'empty' commands.

jvguerrero commented 2 years ago

i've updated base.py and used the new connect but it throw me this error TCP packet invalid i've take screenshot before the error Sin título

kurenai-ryu commented 2 years ago

It seems that your device also sends an empty packet, I'm adding a retry in the MR

if this doesn't work, I can only say that the firmware of your device is not supported by this library.

jvguerrero commented 2 years ago

Sir, it doesn't work and continue throw me timeout error. Anyways i really appreciate your time.

I'll give you some information of the my device if u need for some reason or to the future.

Firmware version is 8.0.4.2-5996-01 and when i connect from telnet it show me the next data

image

auriga-ajaytak commented 1 year ago

@jvguerrero Did you find the solution? I am facing the same issue.

@kurenai-ryu Can you please help me with the same issue? Below are my device details.

Platform Information : ZMM200_TFT MCU Version : 14 Firmware Version : Ver 8.0.4.2-20180713 Bio Service : Ver 2.1.12-20180503 Push Service : Ver 2.0.34-20180611 System Version : Ver 17.8.9-20161214

jvguerrero commented 1 year ago

Hi sir, yes i found a solution but finally i used pure python and another library from Oficial ZKTeco 'cause this library use different commands. Btw i haven't tried realtime data but i can access to the general log data from users, and add/modify/delete user templates. Write me joel.ldp2015@gmail.com if want code 'cause idk if github have dm.

Anyways thanks kurenai for your support, this library works fine for me with another device.

duong77476-viindoo commented 1 year ago

Oficial ZKTeco

Hi @jvguerrero could you please give me the name of the library, i think iam facing the same issue here. I would very appreciated, thank you

core-burner commented 2 months ago

This had nothing to do with the library. ZKTEco devices typically do not respond to TCP on 4370. To use TCP, port#4368 needs to be used and this could be pointed out in code. @kurenai-ryu

duong77476-viindoo commented 2 months ago

This had nothing to do with the library. ZKTEco devices typically do not respond to TCP on 4370. To use TCP, port#4368 needs to be used and this could be pointed out in code. @kurenai-ryu

This is wrong, the port is base on machine configuration too

core-burner commented 2 months ago

This had nothing to do with the library. ZKTEco devices typically do not respond to TCP on 4370. To use TCP, port#4368 needs to be used and this could be pointed out in code. @kurenai-ryu

This is wrong, the port is base on machine configuration too

sm I insist. Most Zkteco reader SDK(all that I have seen up to firmware 6.3.x.x) typically connect TCP over 4368, and will RST the SYN if you attempt to do so from 4370. UDP works over 4370. An attempt of TCP will also induce a delay in response so connecting over 4370, making force_udp preferable for faster operation. TCP doesn't function reliably in any ZKT library, but is is supported by additional functionality in the C# etc SDKs where they are used to create COM objects. Screenshot shows the packets of two separate attempts on a random reader that are performed over the two different ports. TCP requests were made over 4370 which fell back to UDP after 4 attempts where 4368 would connect instantly. On the other hand, you won't be able to connect at 4368 over UDP. Regardless TCP on this kind of webserver is very much problematic and ultimately distinction should be made in such a wrapper. Naturally you can do many configurations on many different devices that are not so common. But I have not seen any code contradicting this.