Handle 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.created",
  "object": {
    "type": "live",
    "id": "bbb3bdc4f688349dbf3ea915cc332cde"
  },
  "id": "35e5a3c7-dc6c-4ec4-bc39-a4daf648b014",
  "workspace": {
    "name": "Test",
    "id": "4df2a7f5-d5bf-4074-9adf-d6c4298f363a"
  },
  "data": {
    "streamId": "bbb3bdc4f688349dbf3ea915cc332cde",
    "streamKey": "5678e85797615169cc65a16e81a7b14bkbbb3bdc4f688349dbf3ea915cc332cde",
    "srtSecret": "0994bb5e7267d26b3b1fcb2d9900b41ekbbb3bdc4f688349dbf3ea915cc332cde",
    "trial": false,
    "status": "idle",
    "maxResolution": "1080p",
    "maxDuration": 43200,
    "createdAt": "2025-05-07T06:26:47.677572Z",
    "reconnectWindow": 60,
    "enableRecording": true,
    "mediaPolicy": "public",
    "metadata": {
      "livestream_name": "fastpix_livestream"
    },
    "lowLatency": false,
    "playbackIds": [
      {
        "id": "390fce17-a56e-4614-877a-cd78562d453c",
        "accessPolicy": "public"
      }
    ],
    "srtPlaybackResponse": {
      "srtPlaybackStreamId": "playbbb3bdc4f688349dbf3ea915cc332cde",
      "srtPlaybackSecret": "f3871c91fca6350c2e33969f1ccd4d66kbbb3bdc4f688349dbf3ea915cc332cde"
    }
  },
  "createdAt": "2025-05-07T06:26:49.706068710Z",
  "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" 
    },  
  } 
} 
' 

PLEASE NOTE

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