question

Dyego Costa avatar image
Dyego Costa asked hammer answered

How to handle device discovery websocket error

I'm having trouble handling errors coming from the websocket, looks like when it fails to contact the device it just hangs and never call the callback I provided to initDeviceConnection.

VM189895:2262 deviceSocket.onopen
VM189895:125 Event {isTrusted: true, type: "open", target: WebSocket, currentTarget: WebSocket, eventPhase: 2…}
VM189895:125 Connection Ok
VM189895:125 Connection is slow...no response in 6543 milliseconds
VM189895:125 Connection is slow...no response in 9042 milliseconds
VM189895:266 Server responded with information on how to contact device. Opening communication channel...
VM189895:514 Contacting device at wss://apisandbox.dev.clover.com/support/remote_pay/cs?token=C030UQ53830477
VM189895:2223 contacting device
VM189895:3382 SyntaxError: Unexpected end of input(…)
VM189895:2260 this.deviceSocket = [object WebSocket]
WebSocket connection to 'wss://apisandbox.dev.clover.com/support/remote_pay/cs?token=C030UQ53830477' failed: HTTP Authentication failed; no valid credentials available
VM189895:2280 deviceSocket.onerrordeviceSocket.onerror @ VM189895:2280
VM189895:2281 Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2…}deviceSocket.onerror @ VM189895:2281
VM189895:2292 Clearing ping thread
VM189895:125 CloseEvent {wasClean: false, code: 1006, reason: "", type: "close", target: WebSocket…}
VM189895:2454 attempting reconnect...
VM189895:2223 contacting device
VM189895:3382 SyntaxError: Unexpected end of input(…)
VM189895:2260 this.deviceSocket = [object WebSocket]
VM189895:2274 deviceSocket.onmessage
VM189895:125 Object {id: "1885", method: "DISCOVERY_RESPONSE", packageName: "com.clover.remote.protocol.websocket", payload: "{"merchantId":"6360ZEFK0XCZJ","model":"C300","name…":true,"method":"DISCOVERY_RESPONSE","version":1}", type: "COMMAND"}
VM189895:125 Connection appears to be dead...no response in 11545 milliseconds
WebSocket connection to 'wss://apisandbox.dev.clover.com/support/remote_pay/cs?token=C030UQ53830477' failed: HTTP Authentication failed; no valid credentials available
VM189895:2280 deviceSocket.onerrordeviceSocket.onerror @ VM189895:2280
VM189895:2281 Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2…}deviceSocket.onerror @ VM189895:2281
VM189895:2292 Clearing ping thread
VM189895:125 CloseEvent {wasClean: false, code: 1006, reason: "", type: "close", target: WebSocket…}
VM189895:2454 attempting reconnect...
VM189895:2223 contacting device
VM189895:2274 deviceSocket.onmessage
VM189895:3382 SyntaxError: Unexpected end of input(…)
VM189895:2260 this.deviceSocket = [object WebSocket]
WebSocket connection to 'wss://apisandbox.dev.clover.com/support/remote_pay/cs?token=C030UQ53830477' failed: HTTP Authentication failed; no valid credentials available
VM189895:2280 deviceSocket.onerrordeviceSocket.onerror @ VM189895:2280
VM189895:2281 Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2…}deviceSocket.onerror @ VM189895:2281
VM189895:2292 Clearing ping thread
VM189895:125 CloseEvent {wasClean: false, code: 1006, reason: "", type: "close", target: WebSocket…}
VM189895:2454 attempting reconnect...
VM189895:2223 contacting device
VM189895:3382 SyntaxError: Unexpected end of input(…)
VM189895:2260 this.deviceSocket = [object WebSocket]
VM189895:125 Connection Ok
WebSocket connection to 'wss://apisandbox.dev.clover.com/support/remote_pay/cs?token=C030UQ53830477' failed: HTTP Authentication failed; no valid credentials available
VM189895:2280 deviceSocket.onerrordeviceSocket.onerror @ VM189895:2280
VM189895:2281 Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2…}deviceSocket.onerror @ VM189895:2281
VM189895:2313 Exceeded number of reconnect attempts, giving up. There are 0 messages that were queued, but not sent.WebSocketDevice.startupReconnect @ VM189895:2313deviceSocket.onerror @ VM189895:2283
VM189895:125 Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2…}
VM189895:2292 Clearing ping thread
VM189895:125 CloseEvent {wasClean: false, code: 1006, reason: "", type: "close", target: WebSocket…}
VM189895:2274 deviceSocket.onmessage
VM189895:125 Connection Ok
2VM189895:2274 deviceSocket.onmessage
VM189895:125 Connection Ok
VM189895:2274 deviceSocket.onmessage
VM189895:125 Connection Ok
2VM189895:2274 deviceSocket.onmessage
VM189895:125 Connection Ok
VM189895:2274 deviceSocket.onmessage
VM189895:125 Connection Ok
2VM189895:2274 deviceSocket.onmessage
VM189895:125 Connection Ok
3VM189895:2274 deviceSocket.onmessage
VM189895:125 Connection Ok
3VM189895:2274 deviceSocket.onmessage
VM189895:125 Connection Ok

Is it possible to handle the websocket communication failure?

VM189895:2313 Exceeded number of reconnect attempts, giving up. There are 0 messages that were queued, but not sent.WebSocketDevice.startupReconnect @ VM189895:2313deviceSocket.onerror @ VM189895:2283
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

hammer avatar image
hammer answered

This may be a version issue. Please see the new npm module for an updated version. See http://devask.clover.com/question/242...

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