caobo171 / node-zklib

This is a lightweight of node.js module to connect to biometrix attendance device for examples ZKTeco
70 stars 59 forks source link

Using TCP on port 80 #25

Closed riadh2002 closed 4 years ago

riadh2002 commented 4 years ago

If I try to set the port to TCP80 instead of UDP4370 let zkInstance = new ZKLib(192.168.1.202, 80, 10000, 4000);

I get the follwing error:

ZKError { err: Error: TIMEOUT_ON_WRITING_MESSAGE at Timeout. (nodejs\node_modules\node-zklib\zklibtcp.js:100:22) at listOnTimeout (internal/timers.js:549:17) at processTimers (internal/timers.js:492:7), ip: '192.168.1.202', command: 'TCP CONNECT' }

is there any other considerations to take into account to use TCP instead of UDP?

the reason of using TCP is to get more user info (password, cardID) which are not available through UDP

thanks

caobo171 commented 4 years ago

Oh, it depends on your device, some device use UDP, some use TCP, I covered it in my code, but I didn't see a device use port 80 before, it usually uses port 4370 both for TCP or UDP

riadh2002 commented 4 years ago

Thanks,

it seems the TCP error is also thrown if a pointing device is outside the local network example: ip=device.ddns.net that resolves to 80.90.100.110, even-though both TCP80 and UDP4370 ports are open and the device is accessible using ZK software

ZKError { err: Error: connect ETIMEDOUT 80.90.100.110:4370 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) { errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect', address: '80.90.100.110', port: 4370 }, ip: 'device.ddns.net', command: 'TCP CONNECT' }

I wonder if there is a port problem here?

riadh2002 commented 4 years ago

Hello again,

OK using your comment about port 4370 as UDP and TCP, I opened port 4370 on TCP and tried and it worked!!!

So for this to work, port 4370 must be open on both TCP and UDP and the program chooses which one to use.

But one issue is when the program chooses TCP, the getUsers will not return the password and Card Number?

thank you

caobo171 commented 4 years ago

Thanks,

it seems the TCP error is also thrown if a pointing device is outside the local network example: ip=device.ddns.net that resolves to 80.90.100.110, even-though both TCP80 and UDP4370 ports are open and the device is accessible using ZK software

ZKError { err: Error: connect ETIMEDOUT 80.90.100.110:4370 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) { errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect', address: '80.90.100.110', port: 4370 }, ip: 'device.ddns.net', command: 'TCP CONNECT' }

I wonder if there is a port problem here?

I think it's my lib's problem, but I can't fix this now with my resource, all my test devices are used in my company so it's hard for me to request them open another port

caobo171 commented 4 years ago

Hello again,

OK using your comment about port 4370 as UDP and TCP, I opened port 4370 on TCP and tried and it worked!!!

So for this to work, port 4370 must be open on both TCP and UDP and the program chooses which one to use.

But one issue is when the program chooses TCP, the getUsers will not return the password and Card Number?

thank you

glad to hear that, the missing properties is caused by lacking document, I don't know how to extract it :(