clover / remote-pay-windows

Clover SDK for Windows PoS Integration
https://www.clover.com/integrations
Other
21 stars 31 forks source link

POS stops receiving messages if USBCloverTransport .receiveString() raises an error #52

Open Simon-ReScan opened 5 years ago

Simon-ReScan commented 5 years ago

We are experiencing an intermittent issue in production, where the Clover will accept messages from the POS but the POS does not get messages from the Clover. In event viewer we found the following events, just before this happens

14:13:10 - receiveMessagesThread Exception: Read failed, 0 bytes returned 14:13:10 - 4 : Terminating receiveMessagesThread

We managed to track this down to getMessages()in USBCloverTransport.cs, this method calls receiveString() , if receiveString() raises an exception getMessages() exits its loop and the POS will no longer receive messages.

This results is the POS been able to initiate a payment on the Clover and the Cover been able to process the payment, but the payment response will never make it back to the POS.

In the case of the above error, we believe this is down to the UsbEndpointReader, calling Read on line 959 of the readPacket() method, and having an unexpected result with numBytesRead still been zero, this in turn raise an exception, to break out of the loop, which is sollowed up by the empty try-catch, losing the reason for the failure.

As numBytesRead is zero it then raises an exception on line 977, this is the error we are seeing in event viewer.

We have been able to replicate this by setting a break point at line 961 and setting ecRead = UnknownError and numBytesRead = 0. After this the POS can still communicate with the Clover, but the Clover and no longer communicate with the POS.

We are using v4.0.2 / .net 4.5 and have seen this on both Windows 7 & 10

jwhitted-clover commented 5 years ago

@Re-scan Thanks for the very detailed writeup! I have a PR out now with a fix for this.

schwartztr commented 4 years ago

Does the 4.0.3 release include the fix for this?

jwhitted-clover commented 4 years ago

@schwartztr The new USB Transport no longer uses this method to read packets. This problem should be resolved in 4.0.3.

TrueOX commented 4 years ago

I can confirm this issue is not resolved in 4.0.3. My program is using 4.0.3 and It has the same exact problem.