question

junsuhlee94 avatar image
junsuhlee94 asked David Marginian Deactivated commented

How to implement reconnect logic for remote pay cloud?

I'm using Javascript SDK for remote-pay-cloud and sometimes experiencing the disconnection, which is understandable. I wonder how to implement the reconnect logic so that my app can 'try hard' to maintain the healthy connection.

This is what I've tried. OnDisconnected, I tried calling 'initializeConnection()' again. But I got

error Cannot send message, transport is null: {"id":"4","type":"COMMAND","packageName":"com.clover.remote.protocol.websocket","method":"DISCOVERY_REQUEST","payload":"{\"method\":\"DISCOVERY_REQUEST\",\"version\":0,\"supportsOrderModification\":false}","remoteSourceSDK":"com.clover.cloverconnector.cloud:3.1.0","remoteApplicationID":"17GTAPT6R62MP","version":2}
I also put .setReconnectDelay(3000) as well when initial connection, but looks like it is not really retrying connection when disconnected.

It would be great if you can help me building good reconnection logic!
Cloud Pay DisplayRemote Pay Cloud
10 |2000

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

1 Answer

junsuhlee94 avatar image
junsuhlee94 answered junsuhlee94 commented
@David Marginian

Thank you so much for quick reply.
I've set heartbeat, however this is what I've been getting it.

First,
onDeviceDisconnected

and then
onDeviceError CloverDeviceErrorEvent { "_class_": [Function CloverDeviceErrorEvent], "cause": null, "code": "NotConnected", "message": "In showWelcomeScreen: Device is not connected.", "type": "COMMUNICATION", }
above is perhaps because my app tried to show some screen, which is fine. And then I think the next is something that SDK do for retry?

error Cannot send message, transport is null: {"id":"8","type":"COMMAND","packageName":"com.clover.remote.protocol.websocket","method":"DISCOVERY_REQUEST","payload":"{\"method\":\"DISCOVERY_REQUEST\",\"version\":0,\"supportsOrderModification\":false}","remoteSourceSDK":"com.clover.cloverconnector.cloud:3.1.0","remoteApplicationID":,"version":2}

Those are what I got when I set the heartbeat

10 |2000

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