---
title: Heartbeats
description: As part of the keep-alive strategy for Doshii WebSocket connections, it is necessary to be capable of sending and receiving heartbeats on an established WebSocket connection. As described in the artic
---

[Skip to content](https://support.doshii.com/developer-support/hc/en-us/articles/360007479253-heartbeats#main-content)

English

Show submenu for translations

Doshii Connect Pty Ltd

Open main navigation

Close main navigation

- English
  
  Show submenu for translations
- Go to Doshii Connect Pty Ltd

 Go to Doshii Connect Pty Ltd

 Help for Partners

- There are no suggestions because the search field is empty.

1. [Help for Partners](https://support.doshii.com/developer-support?hsLang=en)
2. [WebSocket - POS partners](https://support.doshii.com/developer-support/websocket-pos-partners?hsLang=en)

# Heartbeats

As part of the keep-alive strategy for Doshii WebSocket connections, it is necessary to be capable of sending and receiving heartbeats on an established WebSocket [connection](https://support.doshii.io/hc/en-us/articles/360000420274).

## Initiated by Client

As described in the article, [Use of WebSockets](https://support.doshii.io/hc/en-us/articles/360000649613), it is necessary to periodically send a heartbeat (ping) to Doshii to help maintain the connection and ensure Doshii does not treat the connection as inactive. The recommended interval is every 30 seconds.

The ping event should be of the form:

```
{
    "doshii": {
        "ping": <unix time in milliseconds>,
        "version": "<pos version>"
    }
}
```

e.g.

```
{
    "doshii": {
        "ping": 1539144663417,
        "version": "5.3.72"
    }
}
```

An example, using NodeJS for the ping event:

```
ws.on('open', function(event) {
  function heartbeat() {
    const timestamp = Date.now();
    const posVersion = '5.3.72';
    const payload = JSON.stringify({
        doshii: {
            ping: timestamp,
            version: posVersion
        }
    });
    ws.send(payload);
  }

  heartbeat(); // Send one immediately to complete the handshake
  setInterval(heartbeat, 30000); // Then 30 every seconds or so thereafter to keep alive
});
```

The ping event also supports an optional status property that can contain one or many properties to indicate the current health of the POS:

```
{
    "doshii": {
        "ping": 1539144663417,
        "version": "5.3.72",
        "status": {
            "database": "online",
            "processor": "offline"
        }
    }
}
```

In response to the ping event, Doshii will respond with a [pong](https://support.doshii.io/hc/en-us/articles/360000408473) event. Responding with the unix time in milliseconds that was supplied in the original ping, along with the current API version.

```
{
    "type": "message",
    "data": { "doshii": { "pong": 1539153237588, "version": "3.2.0" } }
}
```

## Initiated by Doshii (Health Check)

Similar to the heartbeat logic described above, Doshii will also periodically send its own "[ping](https://support.doshii.io/hc/en-us/articles/360010375973)" message on the established connection, in the form of a [health\_check](https://support.doshii.io/hc/en-us/articles/360010375973) event, expecting to receive a pong as a response.

```
EVENT health_check
```

```
{
    "type": "health_check",
    "data": {
        "ping": 1539153237588
    }
}
```

In response to the health check event, it is expected that your POS system will respond with a "pong" in the same format that the standard heartbeat uses, including the POS version and any status information. Responding with the unix time in milliseconds that was supplied in the original ping.

```
{
    "doshii": {
        "pong": event.ping,
        "version": "5.7.13",
        "status": {
            "database": "online",
            "processor": "online"
        }
    }
}
```

 

- [API concepts](https://support.doshii.com/developer-support/api-concepts?hsLang=en)
- [Members](https://support.doshii.com/developer-support/members?hsLang=en)
- [Model](https://support.doshii.com/developer-support/model?hsLang=en)
- [FAQ - Developers](https://support.doshii.com/developer-support/faq-developers?hsLang=en)
- [Resources](https://support.doshii.com/developer-support/resources?hsLang=en)
- [Orders](https://support.doshii.com/developer-support/orders?hsLang=en)
- [Rewards](https://support.doshii.com/developer-support/rewards?hsLang=en)
- [Check-ins](https://support.doshii.com/developer-support/check-ins?hsLang=en)
- [Getting started - App partners](https://support.doshii.com/developer-support/getting-started-app-partners?hsLang=en)
- [Employees](https://support.doshii.com/developer-support/employees?hsLang=en)
- [Getting started - Doshii Dashboard](https://support.doshii.com/developer-support/getting-started-doshii-dashboard?hsLang=en)
- [Quick start for developers](https://support.doshii.com/developer-support/quick-start-for-developers?hsLang=en)
- [Onboarding](https://support.doshii.com/developer-support/onboarding?hsLang=en)
- [Location](https://support.doshii.com/developer-support/location?hsLang=en)
- [All App Partners Event](https://support.doshii.com/developer-support/all-app-partners-event?hsLang=en)
- [Menus](https://support.doshii.com/developer-support/menus?hsLang=en)
- [Loyalty / Checkins](https://support.doshii.com/developer-support/loyalty-checkins?hsLang=en)
- [WebSocket - App partners](https://support.doshii.com/developer-support/websocket-app-partners?hsLang=en)
- [All POS vendor events](https://support.doshii.com/developer-support/all-pos-vendor-events?hsLang=en)
- [Loyalty / Gift Cards](https://support.doshii.com/developer-support/loyalty-gift-cards?hsLang=en)
- [Devices](https://support.doshii.com/developer-support/devices?hsLang=en)
- [Tables](https://support.doshii.com/developer-support/tables?hsLang=en)
- [Workflows](https://support.doshii.com/developer-support/workflows?hsLang=en)
- [FAQ - Doshii Dashboard](https://support.doshii.com/developer-support/faq-doshii-dashboard?hsLang=en)
- [Bookings](https://support.doshii.com/developer-support/bookings?hsLang=en)
- [Transactions](https://support.doshii.com/developer-support/transactions?hsLang=en)
- [Webhooks](https://support.doshii.com/developer-support/webhooks?hsLang=en#main-content)

    - [App Partners](https://support.doshii.com/developer-support/webhooks?hsLang=en#app-partners)
    - [POS Vendors](https://support.doshii.com/developer-support/webhooks?hsLang=en#pos-vendors)
- [App Partner Guide](https://support.doshii.com/developer-support/app-partner-guide?hsLang=en)
- [Authentication](https://support.doshii.com/developer-support/authentication?hsLang=en)
- [Getting started - POS vendors](https://support.doshii.com/developer-support/getting-started-pos-vendors?hsLang=en)
- [Ordering](https://support.doshii.com/developer-support/ordering?hsLang=en)
- [Reservations](https://support.doshii.com/developer-support/reservations?hsLang=en)
- [Pilot](https://support.doshii.com/developer-support/pilot?hsLang=en)
- [Bulk data](https://support.doshii.com/developer-support/bulk-data?hsLang=en)
- [Playbooks](https://support.doshii.com/developer-support/playbooks?hsLang=en)
- [Rejection codes](https://support.doshii.com/developer-support/rejection-codes?hsLang=en)
- [Getting started](https://support.doshii.com/developer-support/getting-started?hsLang=en)
- [WebSocket - POS partners](https://support.doshii.com/developer-support/websocket-pos-partners?hsLang=en)
- [Events - App partners](https://support.doshii.com/developer-support/events-app-partners?hsLang=en)
- [Service channels](https://support.doshii.com/developer-support/service-channels?hsLang=en)
- [Events](https://support.doshii.com/developer-support/events?hsLang=en)
- [Concepts](https://support.doshii.com/developer-support/concepts?hsLang=en)
- [Apps](https://support.doshii.com/developer-support/apps?hsLang=en)

# Doshii Connect Pty Ltd

Doshii Connect Pty Ltd Help Center

Copyright © 2026, Doshii Connect Pty Ltd