ConnectivityTask
components/tasks/ConnectivityTask.brs is a background Task node that runs an infinite polling loop. It wakes up on a 10-second timer tick and calls DoCheck(), which performs an HTTP probe against the active server’s health endpoint.
The
checkNow field allows other parts of the app to trigger an immediate check outside the normal 10-second cadence — for example, when the player encounters a stream error.Retry interval
The constantNET_RETRY_MS = 30000 in AppConstants.brs defines the interval used by higher-level retry logic (e.g., the player’s reconnection policy). The task’s own internal polling cycle runs at 10 seconds, independent of NET_RETRY_MS.
Online/offline state in DoCheck()
DoCheck() writes the result of each probe to both the task’s own output field and to m.global:
Log spam suppression
The task tracks the previous state inm.lastConnectivityState. A log or warning is only emitted when the state changes — not on every poll tick. A device that stays offline for minutes will produce a single "No internet reachability" warning rather than one every 10 seconds.
Global state fields written
| Field | Type | Description |
|---|---|---|
m.global.hasInternet | Boolean | true if the health probe succeeded |
m.global.isOnline | Boolean | true if the device has any network interface (from GTV_IsOnline()) |
m.top.hasInternet | Boolean | Task output field; mirrors m.global.hasInternet |
NetworkDetector utility
source/utils/NetworkDetector.brs provides two low-level functions that DoCheck() and other utilities use:
GTV_IsOnline() uses the Roku roDeviceInfo API — it only confirms that a network interface exists (Wi-Fi or Ethernet is connected), not that the internet is reachable. GTV_HasInternet() adds a server probe on top of that, making it suitable for callers that need confirmed reachability rather than just interface presence.
HealthCheck utility
source/utils/HealthCheck.brs contains the GTV_PingServer() function used by all connectivity probes:
- The endpoint probed is
baseUrl + "/health"(PATH_HEALTH = "/health"inAppConstants.brs). - The timeout is
TIMEOUT_HEALTH = 2500ms — fast enough to not block the UI. - Any HTTP response code in the range 200–499 is treated as success. This means a
404or401from the server still counts as “reachable”; only network-level failures or a5xxcause the probe to returnfalse. - HTTPS connections use the Roku CA bundle at
common:/certs/ca-bundle.crt.
How the app responds to connectivity loss
Player screen
Player screen
The
PlayerScreen monitors m.global.hasInternet. When it goes false, the player shows an offline error modal and pauses stream attempts. It does not immediately stop the video — if the stream buffer holds, playback may continue briefly. Once the modal is visible, the player retries reconnection on a NET_RETRY_MS = 30000 ms interval.Auth and playlist tasks
Auth and playlist tasks
If
AUTH_REASON_NETWORK_DOWN is returned from an auth or playlist HTTP call (HTTP code -1), MainScene shows an OfflineDialog with a retry button rather than logging the user out. The retry re-runs the handshake flow from the beginning.Session auth checks
Session auth checks
The periodic session re-auth timer (
SESSION_AUTH_CHECK_MS = 420000 ms) skips its check when m.global.isOnline or m.global.hasInternet is false, avoiding spurious session-expiry dialogs during a network outage.Connectivity task itself
Connectivity task itself
The task continues polling regardless of state. As soon as the probe succeeds again,
m.global.hasInternet returns to true, and any subscriber that observes that field can resume normal operation.