Skip to main content
c.Apps.Realtime(ctx, appID) opens a live stream of an app’s logs, status and system events and returns a *squarecloud.Realtime. It is an iterator: call Next in a loop until it returns an error, and always Close it.
The ctx passed to Realtime governs the whole stream: Next takes no arguments. To stop a loop blocked in Next from another goroutine, cancel that ctx.

Events

Every RealtimeEvent has Event, Data (the raw frame text) and ID (the last event id, "" if none).

The Status struct

Ending the stream

Next returns io.EOF when:
  • the server closes the connection cleanly (each connection lasts up to 10 minutes);
  • the server sent REALTIME_DISCONNECTED (the event is delivered first, then io.EOF);
  • you called Close.
When the ctx passed to Realtime is canceled or its deadline passes, Next returns the bare ctx.Err() (context.Canceled or context.DeadlineExceeded), not an *APIError. To leave the loop yourself, just break: the deferred Close releases the connection. To keep watching past 10 minutes, call Realtime again when the loop ends.

Reconnection

A dropped connection, or the server handing reconnection to the client (REALTIME_RECONNECT), reopens the stream on its own:
  • up to 3 times in a row; any logs or status event resets the count;
  • each reopen at least 5.5 s after the previous open, to stay under the API’s pace of one open per 5 seconds per app.
The merged Status survives reconnections. Past 3 failed reconnections, Next returns an *APIError with NETWORK_ERROR (status 0).

Limits and errors

  • 5 concurrent connections per account and 30 per app, across all users. Going over is 429 REALTIME_MAX_CONNECTIONS or REALTIME_MAX_CONNECTIONS_APP.
  • The HTTP status is checked before streaming, so these errors (and 404 for an unknown app) are returned by Realtime itself, before the first Next.
  • When ctx has no deadline, the WithTimeout deadline only covers the open, until the response headers arrive (TIMEOUT if they don’t). The stream itself has no deadline besides ctx.

Next steps

Snapshots

Back up and restore apps and databases.

Realtime API reference

The REST endpoint behind this stream.

Logs from the CLI

The same stream from the terminal.