Forbidding Concurrent Stream Playing
In this article we'll quickly see how can you configure Wrench to prevent your users watching your stream concurrently in Wowza Streaming Engine®. First off, you have to be familiar with setting up user authentication using Wrench.
The latest version of Wrench comes out with powerful features that allows you to forbid concurrent playing of your video streams. The configuration parameter you have to use is
wrench.duplicate.check. If set to
true (by default its
<Properties> <Property><Name>wrench.duplicate.check</Name><Value>true</Value></Property> </Properties>
Whenever a new client attempts to connect to your application, its username is resolved by token resolver query (
wrench.token.resolver.sql) and Wrench checks whether there is any active client with the same name.
The limitation of the current implementation is that it does not support clusers. It is on the roadmap to perform duplicate player checks using SQL query, which would allow you to perform this check cluster-wide.
The limit is a per username limit, where the username is determined by the
wrench.token.resolver.sql query based on the token passed by the client. So it is not affected by shared IP address or NAT or anything.
Advanced Concurrent Player Features
Wrench comes with two other nice features related to concurrency. One is that you can set a concurrency limit, say allow 3 people with the same username watching your stream. This can be set by the
wrench.duplicate.limit (default is 1) option. The
wrench.duplicate.drop.other toggle (true / false) allows you to kick off an existing player if someone connects and the limit for that username is exceeded. In that case a previous player with that username is disconnected. In case of RTMP players this results in an immediate black screen, but if you are using HTTP-based streaming, it might take up to a minute for the video to get interrupted, as the player might have already downloaded a long chunk of the stream.
Update: versions from 2015.03.23. support concurrency checking in edge-origin setup as well in a cluster of Wowza Streaming Engine® instances
Duplicate Checking in multi-server scenario
Starting with version 2015.03.26. Wrench is able to check concurrency using the
wrench.duplicate.check.sql SQL query. The idea is that all servers administer connection and disconnection events in a single database table, and duplicate checks are performed against this table. The SQL based checking is turned on by specifying the
wrench.duplicate.check.sql query itself.
Below is a proposed configuration: the
wrench.connect.accept.sql is responsible for the inserts, the
wrench.disconnect.log.time.sql does the cleanup.
<Property> <Name>wrench.duplicate.check</Name> <Value>true</Value> </Property> <Property> <Name>wrench.duplicate.limit</Name> <Value>1</Value> </Property> <Property> <Name>wrench.connect.accept.sql</Name> <Value>insert into wtb_duplicates (clientid,username) values (:clientid, :username)</Value> </Property> <Property> <Name>wrench.disconnect.log.time.sql</Name> <Value>delete from wtb_duplicates where clientid=:clientid and username=:username</Value> </Property> <Property> <Name>wrench.duplicate.check.sql</Name> <Value>select count(id) from wtb_duplicates where username=:username</Value> </Property>