I'm using the JS SDK to communicate with a clover device. When using the initDeviceConnection function to start a connection in order to send a payment to the Clover device sometimes I get the following error upfront:
WebSocket connection to 'wss://apisandbox.dev.clover.com/support/remote_pay/cs?token=C030UQ53830477' failed: HTTP Authentication failed; no valid credentials available
And it tries it until it reaches the maximum allowed attempts:
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...
It doesn't seems to have any consistent reason for receiving this error. After refreshing the page a couple times, with no code change it starts to work. Also the first time I received this I tried to restart the Clover device and afterwards it started to work again, thought I'm pretty sure it was due the time I took to do that.
Also it seems to relate to this question http://devask.clover.com/question/242... Sometimes this problems happens on the first instance of Clover I create, but I always get it after closing the first Clover instance I used, I instantiate a new one and try to initiate a connection to the device.