Unlike a client-side video implementation where the video stream and ads are requested independent of one another, the server-side implementation used with Dynamic Ad Insertion (DAI) requests only one stream, with ads dynamically stitched into the video content. If a server error occurs, the stream can be blocked, which not only provides a poor user experience, but lost revenue.
Ad Manager DAI provides you with HTTP errors when you create a stream as well as when the stream is running, and allows you to specify a backup stream in the event that you do not get a valid response from the server.
Handle HTTP errors detected when a stream is created
Error type | Recommendation |
---|---|
4XX errors (excluding 429) |
When you see HTTP 4XX errors, you should not fall back to the raw streams, as the client likely experienced an error in these instances. Make sure that the request you're sending to the server is correct and contains all of the required parameters. |
429 or 5XX errors | When you see an HTTP 429 or HTTP 5XX errors, you should fall back to the raw backup stream, without monetization. In the IMA SDK, these errors can be caught with an error handler, and the default stream can be switched to the backup stream. |
TVOS
static NSString *const kBackupContentPath =
@"http://googleimadev‑vh.akamaihd.net/i/big_buck_bunny/bbb‑,480p,720p,1080p,.mov.csmil/"
@"master.m3u8";
- (void)streamManager:(IMAStreamManager *)streamManager
didReceiveError:(NSError *)error {
NSLog(@"Error: %@", error);
[self playBackupStream];
}
- (void)playBackupStream {
NSURL *contentURL = [NSURL URLWithString:kBackupContentPath];
self.playerViewController.player = [[AVPlayer alloc] initWithURL:contentURL];
[self.playerViewController.player play];
}
Get the backup stream URL for a video on demand (VOD) or live stream
Your app should have a mechanism to get the backup URL for both VOD and live linear streams. In the case of VOD, the backup stream should be the ingestURL that is provided in the MRSS feed. For live linear, the backup stream should be the content stream specified in the Ad Manager UI.
Handle HTTP errors while the stream is running
If you encounter an error while the stream is running, it is not recommended that you fall back to the raw stream. Ad Manager automatically attempts to correct most of the errors that it encounters. However, in cases where the server is not able to handle an error, the stream stops playing. If the stream stops, the app should initiate a new stream. If the error persists, you should then fall back to the raw stream.
Validate your fallback implementation
You can validate your fallback implementation using the following sample streams:
Stream format | Asset key |
---|---|
HLS | MSQJlB9VSgqJkGNv1mB0FA |
DASH | TrhaCde0R_uKzG_psucTww |
These streams are for testing purposes and will always give an HTTP 429 error.
Automatic failover of DAI Linear streams
In the rare case of unexpectedly high volume to our system, we may fall back to a stream without ads for some users. In that case, the viewer will see underlying content.
In case fallback streams cannot be served (for example, if Authentication or Origin forwarding is specified or if variant exclusion is requested for the stream), an HTTP 429 response code will be served and the application should fall back locally to the raw stream.