#hirshy- Terminal Connection Token

1 messages · Page 1 of 1 (latest)

rotund cipher
#

Hi 👋
Have you configured your integration to listen for reader disconnects?

merry pewter
#

Yes. I have a function running onUnexpectedReaderDisconnect.

rotund cipher
#

What language is your integration written in?

merry pewter
#

JS

rotund cipher
merry pewter
#

Yep

rotund cipher
#

And you have defined the fetchConnectionToken function, correct?

#

If this does generate a request to your back-end to retrieve a connection token, is it possible your back-end is caching the result and returning a stale token?

merry pewter
#

Yes

#

I'd have to check that. But shouldn't the library ask for a new one instead of throwing a rejection?

rotund cipher
#

You mean the JS library? No, it's only configured to request a new one is you disconnect unexpectedly AFAIK. I tested this in my own integration by passing a static token value on my back-end and it does through an error

merry pewter
#

The backend doesn't seem to be caching it.

#

I'm confused as to when this is getting called. According to my logs there wasn't an unexpected disconnect.

#

I attempt to discoverReaders. I get this Uncaught (in promise) and then the discoverReaders resolves with a list of results.

#

I'm not sure who's calling this so that I can catch it. Also, I'm not sure what to do with it once it is caught.

rotund cipher
#

I'm pretty sure this is used internally during the call to terminal.connectReader(), which is why you need to register it when instantiating the StripeTerminal instance.

merry pewter
#

That's not when it was logged. It shows up when I call discoverReaders. I have a catch on that promise but it's still saying "Uncaught". And the discoverReaders comes back with results.

rotund cipher
#

Okay so discoverReaders comes back with results when you get the Uncaught exception? Are you calling initializeTerminal() as part of that function?

#

Also, are you calling initializeTerminal more than once? This could also cause problems.

merry pewter
#

I'm not calling initializeTerminal at all. I've never seen that call in the documentation.

rotund cipher
#

Sorry that was my own code, I meant only initializing the terminal SDK once:

merry pewter
#

Yes. I'm only calling create() once.

rotund cipher
#

So if terminal.discoverReaders returns results, are you able to connect to a reader? Or does the Uncaught exception block all JS?

merry pewter
#

That's a separate issue. When I try to connect to the reader I get a Already have an active connection to a reader. Call 'disconnectReader()' first. error which is also Uncaught (in promise).

rotund cipher
#

Hmmm...okay it seems like the StripeTerminal instance is getting into an invalid state at some point.