How to block Subscribers from Publishing and Playing the streams? #5796
Replies: 1 comment
-
The subscriber block feature allows blocking a specific user from engaging in playback, publishing, or both at any given moment. This implies that even if the user is actively publishing or playing the stream, their ability to publish or play will cease until the block is removed or expires. Block is valid for all publish and play types. To utilize subscriber block for play first enable TOTP(Time-based One-Time Password) for play through web panel application settings. By default, the TOTP generated for playback remains valid for 60 seconds after its generation. Consequently, users intending to utilize this token must send a play request to AMS within this 60-second timeframe. When this setting is enabled users without TOTP wont be able to watch the streams. Now you can send a Example curl: As an illustration, suppose you are associating your users with userIds in your application. When users initiate playback on your application, you can transmit their userId as the subscriberId and issue a TOTP generation request to AMS. Upon receiving the token, pass it to the Ant Media Server SDK, and commence the user's playback. Users must pass TOTP as
Now, you can utilize the subscriber block feature to prevent this user from playing for the desired duration. To do that send a blockType can be "play","publish" or "publish_play" Example request which will block subscriber lastpeony play for 120 seconds: Example curl: After 120 seconds user will be able to play the stream again. To remove the block manually you can pass 0 to the block request. Please notify that playback resumes immediately upon the successful return of this request. For publish process is same with play. Dont forget to save application settings. Now you can send a
Example curl: For example on javascript SDK you should call publish command as follows: Similarly on RTMP publishing you need to pass parameters streamId, subscriberId and subscriberCode.
Since now you are publishing using subscriber TOTP, you can block this subscriber from publishing with block request.
To remove the block pass 0 seconds to request. Keep in mind that if you block subscribers from publishing and then unblock them, they will encounter an "unauthorized_access" error if their TOTP has expired. Consequently, they won't be able to publish even if the block has been lifted. In such instances, you'll need to generate a new TOTP. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a use case where I want users to publish/play the streams for specific durations according to their subscription plan and therefore would like to stop users from publishing and playing streams according to the allotted time.
It seems that the feature to block subscribers from publishing and playing is now available in v2.7.0 as per the release logs https://github.com/ant-media/Ant-Media-Server/releases
Can anyone share with me the steps/configurations needed to achieve this? Also, for which publish and play protocol does this feature apply?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions