# Why use the Pusher protocol instead of designing your own

> Custom realtime protocols often end up as hard-to-maintain binary packets without getting faster. What a client project taught us, what an existing spec, docs and SDKs save you, and where your team's time should go.

Source: https://hibira.io/blog/pusher-protocol-vs-custom
Updated: 2026-11-27

We once took over a client project: realtime sync for a game's lobby and rooms. Who is online, the room list, who joins and leaves a room, and changes to the state inside it. All of this ran on a protocol the team had designed themselves: the client was Unity, the backend handled TCP directly in Go, and messages were custom binary packets. The reasoning made sense at the start. Binary is smaller than text, faster to parse than JSON, and owning the protocol felt more flexible.

Opening the code told a different story. The packet field definitions had one copy in Unity's C# and one in the Go backend, and the Unity side's protocol handling was a separate library that had to be updated whenever the protocol changed. Packets that arrived stuck together or split in half were handled in several different ways, each with its own bugs. The irony was in the newest features: to save time, engineers had simply put a string field in the binary packet and filled it with JSON.

The result: none of the binary complexity went away, none of the JSON parsing cost was saved, and performance didn't really improve. The flexibility of owning the protocol was never used either: the protocol never actually changed during development.

The bigger cost was time. The project spent two years in development, and although it had a production environment, it never launched to the public. Most of the time went into handling connections and concurrency. The reason was simple: the team handled all the low-level TCP mechanics themselves instead of using proven third-party packages, so they had to hit every connection and concurrency pitfall on their own.

This post is about that experience: why custom protocols so often end up here, what the existing Pusher protocol gives you, and when designing your own is still worth it.

## How a custom protocol gets messy

At first a custom protocol seems to need only a few message types. But a realtime protocol you can ship has to answer far more than "what does a message look like":

- How does a connection prove who it is? How does the client know it is connected?
- How do you subscribe and unsubscribe from channels? Who may subscribe to which channel?
- How do you know a connection is still alive? How long without a reply counts as dropped?
- After a disconnect, when should the client reconnect and when not? How long should it wait?
- How are errors expressed, and what should a client do with one?
- When the protocol changes, what happens to older versions of the app?

Each answer has to be designed, built once on every platform and written down. In that client project most of these questions had never been answered formally. They were patched when something broke, so the same thing was done differently in different places.

### TCP doesn't split messages for you

TCP is a stream of bytes, not a series of messages. Send two messages and the other side may receive both stuck together, or half of one. So on raw TCP you design message boundaries yourself, for example a length prefix on every message, and then handle the length itself being split, lengths that make no sense, and connections dropping midway. None of this is hard to write, but it is easy to get wrong, and the bugs only show up on unstable networks, which makes them hard to reproduce.

```text
flow: TCP guarantees the order of bytes, not that a message arrives whole and in one piece
== When sent
Message A --then sends--> Message B
== When received, it may be
A and B stuck together --or--> The first half of A --next read--> The rest of A, then B
```

### Browsers can't use TCP

JavaScript in a web page can't open a TCP connection, and neither can a Unity WebGL build. As soon as the product has to run in a browser, you end up adding WebSocket anyway, or writing a second protocol for the web.

That is what happened to this client project too. Because they wanted an H5 web client, they had to move from raw TCP to WebSocket. A production environment was already running, so they couldn't simply swap it out: the original protocol had to accept both TCP and WebSocket connections on the same port, with the server reading the magic byte at the start of each connection to tell them apart and a switch to toggle between them. There was more to maintain, not less. WebSocket fixed message boundaries and browser support, but the protocol on top was still their own. Authentication, channels, permissions and reconnect rules were still understood only by the team, and every client still had to be written by hand. They replaced the transport, but none of the reinvented wheels.

```text
flow: One port taking two kinds of connections, with the same custom protocol on top
Unity client|raw TCP --binary packets--> The same port|told apart by magic byte --TCP--> Custom protocol|auth, channels, reconnects all hand-written
H5 client|WebSocket --WebSocket--> The same port|told apart by magic byte --WebSocket--> Custom protocol|auth, channels, reconnects all hand-written
```

### Binary is hard to debug

With JSON you open the browser's developer tools and read every message. With a custom binary format you see a run of bytes, and you need to build a tool before you can read it. When front-end, app and back-end engineers chase a bug together, they often get stuck on "what did this packet actually contain?"

With a JSON protocol, every message is readable text. This is Hibira's debug console, where connections, subscriptions and every published event show up as their contents:

![The debug console: connections, subscriptions and every published event, live](https://hibira.io/portal/articles/app-debug-en-light.webp)

### Performance didn't improve, because the bottleneck was never there

Binary is smaller than JSON and faster to parse. That's true. But in most realtime apps, the time between something happening and a user seeing it goes to network round trips, database queries and business logic. Parsing a few hundred bytes of JSON is a tiny slice of that. Making a tiny slice slightly tinier is not something users can feel.

```text
bars: Where a message's time goes (orders of magnitude)
unit: ms
Network round trip (Hong Kong ↔ Tokyo, lowest measured): 51
Database query (typical): 3
*Parsing a 300-byte JSON message: 0.002
```

What does decide realtime performance is whether the server delivers to every connection on time during a spike, and whether one slow connection holds up everyone else. That has nothing to do with binary versus JSON. We wrote about that side in [Why we stopped running our own WebSocket servers](https://hibira.io/blog/hosted-vs-self-hosted-realtime).

### Back to strings and JSON in the end

When every change to the protocol means updating both the backend and that separate Unity library, engineers naturally look for a shortcut: put a string inside the binary packet, fill it with JSON, and add new things to the JSON from then on. That's a reasonable choice, because it makes development faster. But it also shows what matters to a team: being easy to change, read and debug matters far more than saving a few bytes.

```text
flow: How custom protocols tend to evolve
First version|custom binary packets --each protocol change--> Update the backend and the Unity library|encoder, decoder, docs --to save time--> A string inside the binary|JSON inside the string
```

## The Pusher protocol already answers these questions

**Protocol compatibility is not a universal guarantee.** Pusher Channels is a widely adopted, publicly documented *vendor-defined* protocol—not an IETF standard for every realtime use case. Reverb, Soketi, Pusher and Hibira can reuse much of the same client code, but extension support, limits, auth options and operational behaviour can differ. Verify the features your app needs before switching. The timing figures above illustrate orders of magnitude, not a controlled benchmark of these implementations.

WebSocket only carries messages. It doesn't tell you how to subscribe to a channel, how to check permissions, or whether to reconnect after a drop. That is the job of the protocol on top of WebSocket, and that layer already has a standard.

The Pusher protocol is the realtime protocol used by Pusher Channels. After more than a decade in production it has become a widely used ecosystem protocol for channel-based realtime messaging. The specification is public: clients and servers exchange JSON messages over WebSocket, and every question above has a clear answer:

```text
sequence: Connecting and subscribing to a private channel with the Pusher protocol: every step is already defined
Client | Your backend | Compatible realtime service
3 > 1: pusher:connection_established | socket_id
1 > 2: POST /pusher/auth | socket_id, channel_name
2 >> 1: {"auth": "…"} | HMAC SHA256 signature
1 > 3: pusher:subscribe | private-room-42
3 > 1: pusher_internal:subscription_succeeded
note: On a disconnect the error code decides whether to reconnect; client libraries already handle it
```

- **Connection and identity.** Once connected, the server sends `pusher:connection_established` with the connection's socket ID.
- **Channels and permissions.** Public channels are subscribed to directly. Private channels (`private-`) and presence channels (`presence-`) are authorized by your backend with an HMAC SHA256 signature. `private-encrypted-` channels are end-to-end encrypted, so the server can't read their contents.
- **Presence.** Presence channels tell every member who is online, who joined and who left, with nothing for you to design. A game's lobby and its rooms map neatly onto presence channels.
- **Heartbeats.** `pusher:ping` and `pusher:pong` check that a connection is still alive.
- **Errors and reconnects.** Error codes are grouped by behaviour: 4000–4099 don't reconnect, 4100–4199 reconnect after a pause, 4200–4299 reconnect immediately. Client libraries already follow these rules.
- **Publishing from your backend.** Your backend publishes events through a signed HTTP API, with no long-lived connection to keep. Channels becoming occupied or vacated and members joining or leaving can be sent to your backend as webhooks.

These designs look ordinary, but in that client project the team had to work out every one of them on their own.

## The docs and SDKs are already written

Beyond the protocol, the bigger time saver is everything around it:

- **Official and community client libraries.** pusher-js for the web, official libraries for iOS and Android, ready options for Flutter and React Native, and .NET client libraries for C# projects such as Unity.
- **Server libraries for many backend languages.** PHP, Node.js, Ruby, Python, Go, Java and .NET, handling signatures and HTTP API calls.
- **Framework support.** Laravel Broadcasting and Laravel Echo ship with a Pusher driver, and frameworks such as Rails and Django have ready integrations.
- **Docs and examples.** The protocol spec, each library's docs, and plenty of tutorials and answers online. New engineers don't have to learn an internal protocol from scratch.
- **Interchangeable implementations.** Besides Pusher itself, open-source servers such as Laravel Reverb and Soketi and hosted services such as Hibira all speak the same protocol. Write your code once; switching services means changing the host and keys.

With a custom protocol you write all of this yourself, and only your team uses it and only your team can maintain it. When people move on, the knowledge leaves with them.

```text
flow: With an existing protocol, your team only writes the top layer
*Your business logic|chat, notifications, live dashboards --calls--> Existing SDKs|pusher-js, Laravel Echo, server libraries --Pusher protocol--> Any compatible service|Pusher, Reverb, Soketi, Hibira
```

## Where your team's time should go

A realtime protocol is infrastructure. Users won't choose your product because your packets are 20 bytes smaller. They care that chat messages arrive on time, order status updates live and the numbers on the dashboard are right.

Hand protocol design to a standard that has already been proven, and your team can spend its time where it makes a difference: product features, business logic and user experience. It's the same reason you don't write your own database or design your own HTTP.

Building an application is, at heart, integrating resources. Databases, payments, email, sign-in and realtime messaging each have mature standards and services, and the team's job is to combine them into its own product. Building every piece from scratch costs time and leaves the team maintaining things it never needed to own.

## When designing your own is still worth it

An existing protocol isn't the only answer. Designing your own may fit better when:

- **You sync state dozens of times a second or more**, such as player positions in a real-time match, where bandwidth and every millisecond count. Even in games, though, lobbies, rooms, chat and matchmaking notifications don't need a protocol like that. The project we took over was exactly this case: it synced lobby and room state, which a standard protocol handles easily.
- **Devices or networks are very constrained**, such as IoT devices where every byte counts. Specialised standards such as MQTT are worth considering first there.
- **The protocol itself is your product**, and you have the people to maintain it for the long run.

Even then, check that the bottleneck really is the message format before you design your own. Most of the time, measuring first shows the time is going somewhere else.

## Conclusion

A custom protocol doesn't cost you on the first version. It costs you on every change after that, every new platform and every new engineer. That client project wrote a lot of binary handling, performance didn't improve, and the engineers went back to strings and JSON. After moving to WebSocket, they still had a custom protocol on top to maintain. Much of the team's time went into connections and concurrency instead of the game itself.

Realtime messaging doesn't need to be reinvented. [The Pusher protocol](https://hibira.io/pusher-protocol) already defines connections, channels, permissions, presence and reconnects, and the docs and SDKs for every platform already exist, so your team can keep its energy for the business logic that is truly its own. If you're building game lobbies and rooms too, see the [game lobbies use case](https://hibira.io/use-cases/game-lobbies), where rooms, ready states and hosts are built on presence channels. Hibira speaks the Pusher protocol, so the pusher-js, Laravel Echo and server libraries you already use work as they are. The free plan needs no credit card, and if you're on Pusher today, [Migrating from Pusher Channels](https://hibira.io/blog/migrating-from-pusher) walks you through switching without changing your code.
