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.
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
EveryRealtimeEvent 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, thenio.EOF); - you called
Close.
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
logsorstatusevent 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.
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_CONNECTIONSorREALTIME_MAX_CONNECTIONS_APP. - The HTTP status is checked before streaming, so these errors (and 404 for an unknown app) are returned by
Realtimeitself, before the firstNext. - When
ctxhas no deadline, theWithTimeoutdeadline only covers the open, until the response headers arrive (TIMEOUTif they don’t). The stream itself has no deadline besidesctx.
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.

