ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.29k stars 632 forks source link

Subscriber Block Not Working For SRT and RTMP publish #5865

Open lastpeony opened 11 months ago

lastpeony commented 11 months ago

subscriber block feature is not implemented for srt and rtmp publish make it work same with webrtc publish

yashtandon113 commented 11 months ago

@lastpeony

I tested the implementation, and here are the points.

  1. The secret key should be a multiple of 8 bytes instead of a multiple of 6 bytes; otherwise, the TOTP token API throws an internal server error. Currently, the secret key generated via Dashborad is a multiple of 6 bytes.

  2. After using the secret key multiplier of 8 bytes, it works fine with both WebRTC and RTMP.

  3. For SRT, the pattern is not clear on how to use the subscriberId and subscriberCode parameters in a URL.

lastpeony commented 11 months ago

@lastpeony

I tested the implementation, and here are the points.

  1. The secret key should be a multiple of 8 bytes instead of a multiple of 6 bytes; otherwise, the TOTP token API throws an internal server error. Currently, the secret key generated via Dashborad is a multiple of 6 bytes.
  2. After using the secret key multiplier of 8 bytes, it works fine with both WebRTC and RTMP.
  3. For SRT, the pattern is not clear on how to use the subscriberId and subscriberCode parameters in a URL.

1,2-) when i create secret from web panel i face with no problem generating totps. needs more info to reproduce this 3-) for ffmpeg: usr/local/bin/ffmpeg -re -i src/test/resources/test_video_sky_diving_low_latency.flv -codec copy -f flv srt://127.0.0.1:4200?streamid=WebRTCAppEE/stream_3735,subscriberId=subscriber_173,subscriberCode=qwe for obs check documentation there was a small problem with srt subsriber code check. i sent commit to enterprise side to fix it.

yashtandon113 commented 11 months ago
  1. The token issue comes when any user wants to add the subscriber in advance before creating a token. The use of adding a subscriber in advance is to restrict the undefined streams so only added subscribers would be able to publish the stream. The reproduce scenario is as follows:

Expected behavior The token should be generated

Actual behavior The token is not generating and giving the below error

<!doctype html><html lang="en"><head><title>HTTP Status 500 – Internal Server Error</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 500 – Internal Server Error</h1><hr class="line" /><p><b>Type</b> Exception Report</p><p><b>Message</b> Request failed.</p><p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.</p><p><b>Exception</b></p><pre>jakarta.servlet.ServletException: java.lang.IllegalArgumentException: Input is expected to be encoded in multiple of 8 bytes but found: 6
    org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:409)
    org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
    org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:357)
    org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311)
    org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    org.apache.catalina.filters.ExpiresFilter.doFilter(ExpiresFilter.java:1192)
    io.antmedia.filter.IPFilter.doFilter(IPFilter.java:34)
    io.antmedia.filter.ContentSecurityPolicyHeaderFilter.doFilter(ContentSecurityPolicyHeaderFilter.java:32)
    io.antmedia.filter.JWTFilter.doFilter(JWTFilter.java:46)
    org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:331)
    org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:158)
    io.antmedia.filter.RestProxyFilter.doFilter(RestProxyFilter.java:134)
  1. The pattern is clear now and it worked via OBS after launching the server on cloud. I was having some issue in local environment.
lastpeony commented 10 months ago
  1. The token issue comes when any user wants to add the subscriber in advance before creating a token. The use of adding a subscriber in advance is to restrict the undefined streams so only added subscribers would be able to publish the stream. The reproduce scenario is as follows:
  • Generate a secret key from the web panel by enabling TOTP for publish and play
  • Now use that secret key to add the subscriber using this API
  • After adding a subscriber, generate the TOTP token.

Expected behavior The token should be generated

Actual behavior The token is not generating and giving the below error

<!doctype html><html lang="en"><head><title>HTTP Status 500 – Internal Server Error</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 500 – Internal Server Error</h1><hr class="line" /><p><b>Type</b> Exception Report</p><p><b>Message</b> Request failed.</p><p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.</p><p><b>Exception</b></p><pre>jakarta.servlet.ServletException: java.lang.IllegalArgumentException: Input is expected to be encoded in multiple of 8 bytes but found: 6
  org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:409)
  org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:357)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311)
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
  org.apache.catalina.filters.ExpiresFilter.doFilter(ExpiresFilter.java:1192)
  io.antmedia.filter.IPFilter.doFilter(IPFilter.java:34)
  io.antmedia.filter.ContentSecurityPolicyHeaderFilter.doFilter(ContentSecurityPolicyHeaderFilter.java:32)
  io.antmedia.filter.JWTFilter.doFilter(JWTFilter.java:46)
  org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:331)
  org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:158)
  io.antmedia.filter.RestProxyFilter.doFilter(RestProxyFilter.java:134)
  1. The pattern is clear now and it worked via OBS after launching the server on cloud. I was having some issue in local environment.

Please create a new issue on this

yashtandon113 commented 10 months ago

Here is the new issue: https://github.com/ant-media/Ant-Media-Server/issues/5930

mekya commented 6 months ago

Please let me know if any user request this feature and we can increase its priority to merge it faster