October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

Building a Real-Time Whiteboard with WebSockets and Go

WebSockets carry the messages; your Go application must define drawing operations, room membership, ordering, security, and recovery. Here is a practical architecture for a real-time whiteboard.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A real-time whiteboard needs more than a WebSocket connection: it needs a message format, room membership, a rule for ordering drawing operations, and a plan for reconnecting clients. WebSockets provide the persistent, two-way connection; your Go application defines what a drawing event means and which connected users may send or receive it.

A practical first version can use a single Go server to validate each operation, assign it a room sequence number, and broadcast it to that room. Give each connection one reader and one writer, keep outbound queues bounded, and decide how the board is saved before relying on it for durable work.

As an Amazon Associate I earn from qualifying purchases.

What WebSockets do—and what your whiteboard must define

RFC 6455 describes a protocol that begins with an opening handshake and then carries messages over a bidirectional TCP connection. It does not define drawing events, room membership, board storage, or conflict resolution. As the RFC puts it, “The WebSocket Protocol enables two-way communication between a client running untrusted code in a controlled environment to a remote host that has opted-in to communications from that code.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

That distinction matters: a connected browser can exchange messages with your server, but the application still has to decide whether an incoming message is valid, who can send it, how other clients apply it, and what happens if messages arrive late or a connection drops.

#1 Best Overall
Portable Small Dry Erase Board Whiteboard Notebook Handheld-Pink
  • Portable & Lightweight: Size (9.5×6.6 inches), perfect for home, office, and travel. Carry it anywhere with ease.
  • Eco-friendly & Reusable: Interesting alternative to traditional paper notepads. Simply wipe clean with a paper towel to restore a blank surface. Use it over and over again without wasting paper.
  • Smooth Writing & Easy Erasing: The flat and smooth whiteboard surface allows for effortless writing and clean erasing, ideal for quick notes and memo.
  • Erasable Notebook/Notepad: Unique cover design with a soft touch feel, exuding elegance and sophistication. Suitable for both business and study.
  • Great Gift: Includes the whiteboard notebook, cleaning cloth, dry eraser marker. perfect for kids to doodling or practicing their letters and numbers on their very own dry erase notepad.

Choose a small, explicit event protocol

Represent each operation as a typed message rather than sending unstructured coordinates. Give each room, session, and persistent drawing object a stable identifier. If the server assigns ordering, include a sequence number on accepted events; clients can use it to detect gaps and request recovery.

Event Purpose Typical data
stroke.begin Start a stroke Stroke ID, color, width, initial point
stroke.point Add points to an active stroke Stroke ID and one or more points
stroke.end Finish a stroke Stroke ID
shape.add Create a shape Object ID, shape type, geometry, style
object.delete Delete an object Object ID
presence.update Show transient user activity Session ID and cursor or selection state

For example, a client request might look like this:

{
  "type": "stroke.point",
  "roomId": "team-sketch",
  "clientOpId": "op-82",
  "objectId": "stroke-19",
  "points": [{"x": 142, "y": 96}, {"x": 145, "y": 99}]
}

Treat client-provided identifiers and coordinates as input, not as proof of permission or correctness. The server should derive the authenticated user and authorized room membership from its own session state, validate the envelope and payload, then emit an accepted event that includes the server-assigned sequence.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Nu Board A4 Size (8.8 x 11.9 inch) NGA403FN08 Whiteboard Notebook - Dry Erase Notebook - Environmentally Reusable Notebook
  • Size: 223 x 301 mm (8.8 x 11.9 inches) Weight: 415 g (14.6 oz)
  • 4 boards (8 pages); 8 sheets
  • Materials: Paper, Polypropylene
  • Board color: White
  • You can write and erase as many times as you like, so no paper is wasted. It is an Environmentally whiteboard notebook.

Build the connection and room flow in Go

A small deployment can start with an in-memory room hub. The hub owns room membership and serializes accepted operations for each room. A read loop receives and validates messages; the hub applies room authorization, assigns the next sequence, and fans out the accepted event. Each connection’s write loop is the only code that writes to its socket.

  1. Accept a connection. Serve a WebSocket endpoint such as /ws?room=team-sketch. Authenticate the HTTP request, check that the user may join the requested room, and allow only trusted browser origins in the upgrader’s origin check. Use WSS outside local development.
  2. Register the connection. Add it to the authorized room and arrange for a bounded outbound queue and a writer loop. Do not let each incoming handler write directly to every socket.
  3. Read and validate. Decode a message, enforce a maximum message size, check the event type and payload, and check authorization for that specific action.
  4. Order and broadcast. Have one room owner or other serialized mechanism assign the next sequence number and send the accepted event to room members. Decide how the sender receives confirmation and how duplicate client retries are handled.
  5. Remove disconnected clients. On read or write failure, unregister the connection, stop its loops, and release its resources. Also define what happens to a user’s unfinished stroke.

Gorilla WebSocket’s documentation states, “Connections support one concurrent reader and one concurrent writer.” A common design is therefore one read loop and one write loop per connection. The following excerpt illustrates a bounded per-client send queue; it is a building block, not a complete server:

type Client struct {
    conn *websocket.Conn
    send chan []byte // bounded when the client is created
}

func (c *Client) writePump() {
    defer c.conn.Close()
    for message := range c.send {
        if err := c.conn.WriteMessage(websocket.TextMessage, message); err != nil {
            return
        }
    }
}

When the hub broadcasts, it should enqueue rather than write to a socket. If a client’s queue is full, do not block the whole room indefinitely: mark the client for disconnection or recovery and let its writer loop exit cleanly. The queue capacity and the policy for a slow client are deployment decisions, not values specified by WebSocket.

Rank #3
CoBak 6 Sides Portable White Board 12x9 inch (A4)
  • 【6-Sided Whiteboard Notebook】: This A4-sized portable whiteboard notebook features 6 writable surfaces, efficiently meeting various needs like meeting notes, math teaching, brainstorming, and spontaneous creativity. Its flip-page dry-erase design allows for seamless transitions in any setting.
  • 【6-Sided Whiteboard Notebook】: This A4-sized portable whiteboard notebook features 6 writable surfaces, efficiently meeting various needs like meeting notes, math teaching, brainstorming, and spontaneous creativity. Its flip-page dry-erase design allows for seamless transitions in any setting.
  • 【6-Sided Whiteboard Notebook】: This A4-sized portable whiteboard notebook features 6 writable surfaces, efficiently meeting various needs like meeting notes, math teaching, brainstorming, and spontaneous creativity. Its flip-page dry-erase design allows for seamless transitions in any setting.
  • 【6-Sided Whiteboard Notebook】: This A4-sized portable whiteboard notebook features 6 writable surfaces, efficiently meeting various needs like meeting notes, math teaching, brainstorming, and spontaneous creativity. Its flip-page dry-erase design allows for seamless transitions in any setting.
  • 【6-Sided Whiteboard Notebook】: This A4-sized portable whiteboard notebook features 6 writable surfaces, efficiently meeting various needs like meeting notes, math teaching, brainstorming, and spontaneous creativity. Its flip-page dry-erase design allows for seamless transitions in any setting.

Effective Go explains goroutines and channels as tools for concurrent work and synchronization, while warning that unbounded goroutine creation can consume unlimited resources. Apply the same discipline to connection counts, room sizes, queued messages, and shutdown: bound resources, and ensure goroutines stop when a client disconnects or the server shuts down.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep the browser responsive

The browser WebSocket API has no built-in backpressure. MDN warns that if messages arrive faster than the application can process them, memory use can grow or the application can become unresponsive.

  • Batch points from a fast pointer stream into fewer messages instead of sending every raw input independently.
  • Coalesce transient cursor or presence updates so that a newer position can replace an older queued one.
  • Bound server-side outbound queues and choose a clear slow-client policy, such as disconnecting and requiring a resynchronization.
  • Keep durable drawing operations distinct from ephemeral presence. Dropping an old cursor update may be acceptable; silently dropping a committed stroke operation is not.

These are application strategies for dealing with the API’s flow-control limitation; they are not guarantees supplied by WebSockets.

Rank #4
nu board Memo Size (4 x 7 inch) International Edition NASH04US08
  • Size: 104 x 178 mm (4 x 7 inches) Weight: 120 g (4.2 oz)
  • 4 boards (8 pages); 5 sheets
  • Materials: Paper, PET, Polypropylene
  • Board color: White
  • Includes nu board whiteboard marker
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Decide ordering, persistence, and reconnect behavior

For an initial single-server whiteboard, a server-ordered event stream is a straightforward design: the server validates an operation, assigns its place in the room’s sequence, and broadcasts that accepted version. It gives clients a common order for applying events, but the application still has to specify deduplication, replay, and recovery.

Server-ordered operations

Keep a monotonically increasing sequence per room or board. On reconnect, a client can report the last sequence it applied; the server can replay later operations if they remain available, or tell the client to load a snapshot. Define how retries are identified so a reconnecting client does not accidentally apply the same user action twice.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Snapshots plus an operation log

Persist board state periodically as a snapshot and retain subsequent operations in a log. This can make recovery faster than replaying the board’s entire history, but it adds decisions about storage, snapshot versions, log retention, compaction, and what happens if persistence fails. An in-memory hub alone loses its state when the process stops.

Best Value
NEWYES Whiteboard Notebook Erasable A4
  • SMOOTH & DURABLE WRITING SURFACE: NEWYES dry erase board comes with a smooth and durable writing surface, anti-scrap, easy dry wipe and compatible with all dry-erase markers, just like writing on a portable whiteboard
  • MULTIPLE USES: NEWYES whiteboard notebook delivers effective performance for daily, weekly and monthly to do list. In addition to taking note, this white board has applications for managers, teachers, students and kids including presentation, education or darts score counting
  • CONVENIENT SIZE: 11.2 x 8.7 Inch dimensions provide ample writing space. It includes 4 sheets of whiteboards and 5 sheets of transparent boards for writing notes, reminders, and shopping lists
  • ERASABLE AND REUSABLE: When you are going to erase the writing, use the eraser after ink has dried. Erasing prior to ink drying may cause ink to smear and spread. If the whiteboards or sheets become blackened or difficult to erase, use a whiteboard cleaner or alcohol towelettes
  • PACKAGE INCLUDED: 2 Marker Pens cleaning cloth and colorful label index included with your purchase

CRDTs or operational transformation

Consider a conflict-handling model such as a CRDT or operational transformation when offline edits or concurrent multi-writer changes are product requirements. Those approaches require choices about data representation and merge behavior; a WebSocket connection by itself does not provide them. They are not automatically necessary for every whiteboard.

Secure the socket and every operation

OWASP’s WebSocket Security Cheat Sheet recommends secure WebSocket transport, an explicit trusted-origin allowlist, authentication, authorization checks for each action, input validation, reasonable message-size limits, rate limiting, session-expiry handling, and connection cleanup.

  • Use WSS in deployed environments and reject browser origins that are not on your allowlist.
  • Authenticate the connection and check room access before joining; continue checking authorization for operations rather than treating an open socket as blanket permission.
  • Validate message types, required fields, coordinate ranges, object ownership rules, and payload sizes before applying or broadcasting events.
  • Set rate limits appropriate to your application and disconnect or otherwise handle clients that exceed them.
  • Handle session expiry by closing or re-authenticating the connection, and always remove closed clients from room state.
  • Avoid putting credentials in query strings and avoid logging complete message contents or secrets.

The exact limits and authorization rules depend on the application and deployment. The important point is that a WebSocket transports messages; it does not make them trustworthy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A useful first implementation boundary

Start with one authoritative Go process, a small set of typed operations, one ordering rule, bounded per-client queues, and a defined reconnect path. Keep persistence behind a clear boundary so an in-memory prototype can later store snapshots and operations without changing the browser’s basic event vocabulary. Add offline multi-writer conflict handling only if the product needs it.

Quick Recap

Bestseller No. 2
Nu Board A4 Size (8.8 x 11.9 inch) NGA403FN08 Whiteboard Notebook - Dry Erase Notebook - Environmentally Reusable Notebook
Nu Board A4 Size (8.8 x 11.9 inch) NGA403FN08 Whiteboard Notebook - Dry Erase Notebook - Environmentally Reusable Notebook
Size: 223 x 301 mm (8.8 x 11.9 inches) Weight: 415 g (14.6 oz); 4 boards (8 pages); 8 sheets
$26.80
Bestseller No. 4
nu board Memo Size (4 x 7 inch) International Edition NASH04US08
nu board Memo Size (4 x 7 inch) International Edition NASH04US08
Size: 104 x 178 mm (4 x 7 inches) Weight: 120 g (4.2 oz); 4 boards (8 pages); 5 sheets; Materials: Paper, PET, Polypropylene
$16.80

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.