1

Good day,

So I have a c# project that connects to the zkteco time & attendance unit (k30 is the device name)

Sometimes on random when trying to connect I get an error returned from the sdk code -10054

This is my code I use to connect

 bIsConnected = BMDevice.Connect_Net(ipAddress, 4370);

This is the code used to return the error

 BMDevice.GetLastError(ref ErrorCode);

I can't seem to replicate the error and there is no ErrorCode with number -10054 in the documentation provided. I can ping the device and telnet to the ip assigned with the port number, I can also use the device itself.

To get past this I have to manually restart the device and then I can connect without any issues.

Tried asking the zkteco people but the person I spoke to did not help much

Rafael Biz
  • 424
  • 4
  • 19
T.S.G
  • 23
  • 1
  • 2
  • 7
  • Have you tried googling the error code - this seems to be a [sockets error](https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx) WSAECONNRESETindicating the connection has been reset. See this as a possible solution : https://www.pcreview.co.uk/threads/how-to-recover-from-a-wsaeconnreset-10054.2522267/ – PaulF Oct 03 '17 at 13:15
  • I have but I have but mostly for the device itself I will google and see if I get anything else when I just search for the error code. I think you are on point here with that link and it feels like it could be the problem. I do have a disconnect method I can use but it does not take any parameters and even if I use it, it still does not make any difference. Thanks for your comment. – T.S.G Oct 04 '17 at 06:52

1 Answers1

0

The ZKTeco documentation does not explain what -10054 means, but it can be inferred that this error is the WSAECONNRESET socket error.

From MSDN:

Connection reset by peer. An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.

In my experience, the error -10054 mostly happens when there are two ZKTeco devices with the same IP address in the network. That's why you have to manually restart the device.

Rafael Biz
  • 424
  • 4
  • 19