Login

Handling disconnects

Live streaming interruptions can occur due to network issues or errors in streaming software, causing streams to disconnect unexpectedly. FastPix provides built-in mechanisms to handle these disconnects, ensuring a seamless experience for both broadcasters and viewers.

This guide covers:

  • Reconnect Window: How FastPix manages temporary network disruptions.
  • Webhook Events: How to track stream status and automate responses.

Reconnect window

The Reconnect Window determines how long FastPix waits before considering a disconnected live stream as ended. If the network connection is restored within this time frame, the stream resumes seamlessly. Otherwise, it transitions to an idle state, and a media asset is created for the concluded stream.


How it works

  1. Live stream starts: When you start a live stream and connect it to an encoder like OBS, FastPix sends the video.live_stream.connected event.

  1. Media transmission begins: Once the encoder starts sending media to FastPix’s ingest server, the following webhook events are triggered:
    • video.live_stream.active - indicating the stream is now live.
    • video.live_stream.recording - Recording begins if enabled.

  1. Network disruption: If the connection drops, FastPix detects the issue and sends the video.live_stream.disconnected event.

  1. Reconnect window initiates:
    • By default, FastPix waits 60 seconds before declaring the stream as over.
    • If the connection is restored within this period, the stream resumes normally.
    • If the connection is not restored within this period, the stream transitions to an idle state, and FastPix sends the following events:
      • video.live_stream.idle - The stream is no longer active.
      • video.media.created – An on-demand media asset is created for the concluded stream.

Here is a webhook event example when network disruption happens:

{
  "type": "video.live_stream.disconnected",
  "object": {
    "type": "live",
    "id": "2f6159603e66e4fa4e1a04c01942a1c0"
  },
  "id": "e2732338-e0d9-4932-a75d-c79cb1867e6f",
  "workspace": {
    "name": "Testing",
    "id": "89391808-c367-41b2-8561-c6e05ea22dfc"
  },
  "data": {
    "streamId": "2f6159603e66e4fa4e1a04c01942a1c0",
    "streamKey": "1f99c5f81eff38a2d47faae90cfccd87k2f6159603e66e4fa4e1a04c01942a1c0",
    "srtSecret": "6a5c277ea2b1b34e43a25a6a0983b7f5k2f6159603e66e4fa4e1a04c01942a1c0",
    "trial": false,
    "status": "idle",
    "maxResolution": "1080p",
    "maxDuration": 43200,
    "createdAt": "2025-02-25T10:31:40.256173Z",
    "reconnectWindow": 60,
    "enableRecording": true,
    "mediaPolicy": "public",
    "metadata": {
      "livestream_name": "fastpix_livestream"
    },
    "enableDvrMode": false,
    "playbackIds": [
      {
        "id": "3a0f2368-d511-49e7-b2ef-1d277657a96d",
        "accessPolicy": "public"
      }
    ],
    "srtPlaybackResponse": {
      "srtPlaybackStreamId": "play2f6159603e66e4fa4e1a04c01942a1c0",
      "srtPlaybackSecret": "ecbe637f499fb57757fc6d9b9bb49962k2f6159603e66e4fa4e1a04c01942a1c0"
    }
  },
  "createdAt": "2025-02-25T10:38:16.169209504Z",
  "attempts": []
}

Customizing the reconnect window

You can modify the reconnectWindow duration to adjust how long FastPix should wait before marking a stream as ended. Setting a higher value allows more time for recovery from temporary network fluctuations, while a lower value ensures quicker termination if the connection is unlikely to be restored.


curl -X POST https://v1.fastpix.io/live/streams \ 
--user {Access token ID}:{Secret Key} \ 
     -H 'content-type: application/json' \ 
     -d ' 
{ 
  "playbackSettings": { 
    "accessPolicy": "public" 
  }, 
  "inputMediaSettings": { 
    "maxResolution": "1080p", 
    "reconnectWindow": 60, 
    "mediaPolicy": "public", 
    "metadata": { 
      "livestream_name": "fastpix_livestream" 
    }, 
    "enableDvrMode": false 
  } 
} 
' 

PLEASE NOTE

If reconnectWindow is not specified during the API request, it defaults to 60 seconds.