question

Dyego Costa avatar image
Dyego Costa asked Dyego Costa commented

HTTP Authentication failed when using Clover#initDeviceConnection from the JS SDK

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.

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 Dyego Costa commented

The development environment (apisandbox.dev.clover.com) is updated frequently, and this error typically indicates a software update is occurring on the server. This is how the browser is handling the failure of the server to provide SSL information, or there is an issue when upgrading the http(s) connection to ws(s).

Chrome will report this error if there is any issue during the upgrade process.

See https://tools.ietf.org/html/rfc6455#s...

2 comments
10 |2000

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

Dyego Costa avatar image Dyego Costa commented ·

So I shouldn't see this outside the sandbox, in production, right?

I don't actually see it too frequent when I first use the websocket, so the times I've seen it was probably due the reasons you mentioned.

But if I close the connection and then try to open a new one that is always returns those errors. What should I do to avoid that? As I mentioned, I think it might be related to this http://devask.clover.com/question/242...

0 Likes 0 ·
hammer avatar image hammer ♦ commented ·

Your second scenario (But if I close the connection and then try to open a new one...) is related to the issue you linked to.

0 Likes 0 ·

Welcome to the
Clover Developer Community