question

prog2mcbpos avatar image
prog2mcbpos asked David Marginian edited

How I can explicit shutdown the process before onDeviceReady

Environment : SDK cloud, sandbox, nodejs v14.17.5, remote-pay-cloud@4.0.6


Summary : I have a problem with the remote-pay-cloud module-js. It don't have timeout between onDeviceConnected and onDeviceReady.


To recreate the "bug" :

  1. After successful transaction with terminal (connection, call command and dispose).
  2. Simulate communication problem, like disconnect ethernet cable (and no wireless connection).
  3. Rerun script, I have a onDeviceConnected, but never after... nothing... I can reconnect the ethernet cable. Nothing will be trigger. I can wait... some minutes, the script do nothing. (Note : Reconnect ethernet cable will not change anything.)

While script running and waiting for "onDeviceReady ", all other connections is refused (seems normal for security reason). I must kill process manually (like ctrl+c) to stop process


My question is : how I can detect than the script "hang", or instead, how I can explicit shutdown the process (to be add in, by example, a "setTimeout") ?


Note, you can test with "remote-pay-cloud-nodejs-example/lib/ExampleCLI.js".

Sound like https://community.clover.com/questions/23640/how-to-determine-if-connection-failed.html, but finally, not

semi-integrationsRemote Pay Cloud
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
David Marginian avatar image
David Marginian answered David Marginian edited

This doesn't sound like a bug to me. When you disconnect the ethernet cable the SDK will continuously try to establish a connection to the device. If at that point the script is still running and you run it again a connection has already been established to the proxy server and future connections will be blocked. For every call to initialize the connection you need to make sure you dispose of the connection. Please see our best practices here - https://docs.clover.com/docs/remote-pay-sdk-best-practices.

13 comments
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

When I disconnect the cable, the script not running. It's if I running a second time (after disconnect) then I have the problem.

0 Likes 0 ·

I specified on first point that the script has connected, launch command and dispose.

0 Likes 0 ·

The script only disposes of the connector when you explicitly "Exit", are you certain that you are executing the "Exit" option? If you are just killing the script then the connector will not be disposed of properly and subsequent attempts will be blocked. You need to make sure that for every connection initialization dispose is called, in the browser this can be done via onBeforeUnload, but in Node you will need to manage this.

0 Likes 0 ·
prog2mcbpos avatar image prog2mcbpos David Marginian ♦♦ ·

Yes, I'm sure, I dispose. You can use the example CLI for test

[xxx@yyy remote-pay-cloud-nodejs-example]$ node ./lib/ExampleCLI.js
? What action would you like to take? 8. Show Thank You Screen
> Device Connected ...
? What action would you like to take? 99. Exit
Test Completed. Cleaning up.
Exiting example application. To restart please run 'node lib/ExampleCLI.js'

After, I disconnected cable. Then...

[xxx@yyy remote-pay-cloud-nodejs-example]$ node ./lib/ExampleCLI.js
? What action would you like to take? 7. Show Welcome Screen
> Device Connected ...

And stay on this infinity time (more that 10 minutes)


(note : the only thing I change in example script it's prefill answers object/dict.)


0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community