# Pinging Terminal Device

**URL:** <https://developer.squareup.com/forums/t/pinging-terminal-device/11269>\
**Category:** Questions\
**Created:** [November 12, 2023, 4:37am UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269 "2023-11-12T04:37:03Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![bins](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bins](https://developer.squareup.com/forums/u/bins)\
**Post date:** [November 12, 2023, 4:37am UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/1 "2023-11-12T04:37:03Z")

</div>

Hello There,  
Can someone help me understand why I always get the status of the device as “Available”. I turned off the device to check if the status changes to Unavailable but it’s not changing. I am developing a custom POS. I need to ping the device before I send the Total amount to it.

Here is what I have used:

```
    # Set the request headers
    headers = {
        'Authorization': f'Bearer {SQUARE_ACCESS_TOKEN}',
        'Content-Type': 'application/json',
    }

    # Set the device status URL
    device_status_url = f'https://connect.squareup.com/v2/devices/device%3A{SQUARE_DEVICE_ID}'

    # Send a GET request to check the device status
    response = requests.get(device_status_url, headers=headers)
    print(response.text)

```

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [November 13, 2023, 5:18pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/2 "2023-11-13T17:18:42Z")

</div>

How long was the device unavailable. Was it just turned off? 🙂

---

<div class="post-metadata">

**Author:** ![bins](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bins](https://developer.squareup.com/forums/u/bins)\
**Post date:** [November 17, 2023, 10:51pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/3 "2023-11-17T22:51:20Z")

</div>

Yes, for about 5 min. Should it not report if the device has not internet or if it’s turned off?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [November 17, 2023, 10:57pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/4 "2023-11-17T22:57:15Z")

</div>

It definitely should. I haven’t been able to replicate this with my device. Are you able to repeat this consistently? 🙂

---

<div class="post-metadata">

**Author:** ![bins](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bins](https://developer.squareup.com/forums/u/bins)\
**Post date:** [November 22, 2023, 2:22am UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/5 "2023-11-22T02:22:21Z")

</div>

It shows be correct status only after a couple of hours. There ought to be a way to get the device status on a real time basis. Can you suggest me any other way?

thanks

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [November 22, 2023, 4:31pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/6 "2023-11-22T16:31:13Z")

</div>

Is this only happening with one device? If so what’s the `device_id`? 🙂

---

<div class="post-metadata">

**Author:** ![bins](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bins](https://developer.squareup.com/forums/u/bins)\
**Post date:** [November 22, 2023, 9:18pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/7 "2023-11-22T21:18:01Z")

</div>

device:326CS149B4000934

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [November 22, 2023, 10:14pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/8 "2023-11-22T22:14:31Z")

</div>

Are there more devices or is this the only one? 🙂

---

<div class="post-metadata">

**Author:** ![bins](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bins](https://developer.squareup.com/forums/u/bins)\
**Post date:** [November 22, 2023, 11:09pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/9 "2023-11-22T23:09:03Z")

</div>

There are other 4 as well.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [November 22, 2023, 11:55pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/10 "2023-11-22T23:55:06Z")

</div>

All with the same behavior? If so what are there device\_ids? 🙂

---

<div class="post-metadata">

**Author:** ![bins](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bins](https://developer.squareup.com/forums/u/bins)\
**Post date:** [November 23, 2023, 2:58am UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/11 "2023-11-23T02:58:17Z")

</div>

Have not checked with other devices as they are located at different places.

---

<div class="post-metadata">

**Author:** ![bitbaker](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@bitbaker](https://developer.squareup.com/forums/u/bitbaker)\
**Post date:** [December 11, 2023, 7:16pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/12 "2023-12-11T19:16:05Z")

</div>

Hello, I just wanted to drop my 2 cents here. I too have noticed that the device status does not update when using the new “device status” end point. I’ve tried multiple times, across multiple API versions and it never quite does what you expect. I just assumed that it’s not close to real time (I would consider sub 10 sec bare minimum for “real time”). We really need a way to know if the device is ready before we start sending requests, it would help smooth out dealing with the device.

I have resorted to keeping a heart beat going on the back end, and then having the front end request the current status of the heart beat. The heart beat is on ~30 sec intervals, which is still not fast enough. But I’ve found that any faster and I start to get false positives.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 11, 2023, 8:44pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/13 "2023-12-11T20:44:34Z")

</div>

How are you using the ping? Are you doing it before every payment? Or are you periodically checking? 🙂

---

<div class="post-metadata">

**Author:** ![BrianC](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/brianc/32/112_2.png) [@BrianC](https://developer.squareup.com/forums/u/BrianC)\
**Post date:** [December 15, 2023, 1:38am UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/14 "2023-12-15T01:38:32Z")

</div>

Periodic check (aka “heartbeat”), every 30 seconds, assuming I’m understanding correctly.

---

<div class="post-metadata">

**Author:** ![bitbaker](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@bitbaker](https://developer.squareup.com/forums/u/bitbaker)\
**Post date:** [December 17, 2023, 7:42pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/15 "2023-12-17T19:42:19Z")

</div>

I just double checked and forgot that I had to set the interval to 60 seconds. I forgot why I had to do that now.

I have a small backend (nodejs server) running locally on the machine. It handles keeping the heartbeat going, even when the client is not interacting with the API or the server. The server saves the last status it got from the ping as a bool. The client asks the back end for the latest status of the device throughout various operations (when the user connects, when the users wants to get payment, etc).

The backend sends out a terminal action for pinging the device, then about ~60 seconds later, it checks the status of the ping/action. If the backends detects a bad status from the device, it sends out a terminal action as usual, but the status of that same action is checked more frequently, about every 15 seconds, until that action times out. At which point it will send another action and this repeats until the we get a good status update.

I don’t really like my solution. I would rather just ask the API if the device is ready. But as I’ve pointed out before, it doesn’t behave as expected.

One test I conducted was asking the API for the device status (using the new endpoint for doing so) every like 10 seconds or so. And then I would turn the device off and watch the responses from the API. Minutes would go by before the status would change. Not sure if that was the intended behavior.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 18, 2023, 5:34pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/16 "2023-12-18T17:34:42Z")

</div>

I’m reaching out to the team about this. I was able to replicate the delayed behavior. 🙂

---

<div class="post-metadata">

**Author:** ![bitbaker](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@bitbaker](https://developer.squareup.com/forums/u/bitbaker)\
**Post date:** [December 18, 2023, 8:21pm UTC](https://developer.squareup.com/forums/t/pinging-terminal-device/11269/17 "2023-12-18T20:21:38Z")

</div>

I’ve been writing in another post ([WEIRD problem with my square terminal](https://developer.squareup.com/forums/t/weird-problem-with-my-square-terminal/4034)) about another problem I was having. Turns out doing the pinging strategy I describe above causes the device to take an unacceptable length of time before it would acknowledge the checkout request. Oddly, if I touched the screen while waiting, the device would immediately acknowledge the request.

I make mention of this here so people don’t go doing what I did. Our best bet is to wait for the devs to provide a solid endpoint for this kinda thing. Trying to do anything close to real time with the provided APIs seems to cause the device/service to behave oddly.
