aws / amazon-ivs-react-native-player

A React Native wrapper for the Amazon IVS iOS and Android player SDKs.
Apache License 2.0
299 stars 31 forks source link

Player does not respect Redirection from HTTP response #84

Open arthurgeron-work opened 2 years ago

arthurgeron-work commented 2 years ago

Describe the bug The stream URL responds with a different 'Location' header, it ignores that and tries to stream data from the same domain but with a mangled path.

To reproduce Steps to reproduce the behavior. Utilize a endpoint that returns a Location header pointing to the stream file in a Storage service (e.g. gcp, AWS S3, etc)

Expected behavior The player should load from the proper "new" location (e.g. be redirected) using the Location header data.

Screenshots

The request:

Captura de Tela 2022-08-10 às 22 23 50

The location header:

Captura de Tela 2022-08-10 às 22 24 03

Expected behavior:

Captura de Tela 2022-08-10 às 22 26 25

How it behaves:

Captura de Tela 2022-08-10 às 22 27 12

Device (please complete the following information):

Debug logs (Errors bellow are due to the player trying to load the stream from a mangled path):

Error 500:  (MediaPlaylist: ErrorNetwork)
[Error: Request failed with status code 503]

Additional context The expected behaviour comes from a package that I used before called react-native-aws-ivs-player which reacted correctly to the http redirection.

HTTP Response data:

{
  "id": 415401149733227800,
  "requestTime": "2022-08-11T01:30:37.419Z",
  "method": "GET",
  "url": "https://hml-mobile.tradersclub.com.br/tcmediaapi/v1/file/hls/6524ac42-fb1b-4c10-a96a-a2f088448913.m3u8",
  "domain": "hml-mobile.tradersclub.com.br/tcmediaapi/v1/file/hls/6524ac42-fb1b-4c10-a96a-a2f088448913.m3u8",
  "requestHeaders": [
    {
      "value": "application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain",
      "key": "Accept"
    }
  ],
  "responseTime": "2022-08-11T01:30:37.589Z",
  "status": 307,
  "reason": "temporarily redirected",
  "responseHeaders": [
    {
      "value": "h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400",
      "key": "Alt-Svc"
    },
    {
      "value": "cloudflare",
      "key": "Server"
    },
    {
      "value": "DYNAMIC",
      "key": "cf-cache-status"
    },
    {
      "value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
      "key": "expect-ct"
    },
    {
      "value": "https://storage.googleapis.com/tc-media-storage-hml/hls/6524ac42-fb1b-4c10-a96a-a2f088448913/6524ac42-fb1b-4c10-a96a-a2f088448913.m3u8",
      "key": "Location"
    },
    {
      "value": "Thu, 11 Aug 2022 01:30:37 GMT",
      "key": "Date"
    },
    {
      "value": "max-age=31536000; includeSubDomains; preload",
      "key": "Strict-Transport-Security"
    },
    {
      "value": "b13ac13f-ad8c-4521-b5ff-54741cdc9c7d",
      "key": "x-request-id"
    },
    {
      "value": "0",
      "key": "Content-Length"
    },
    {
      "value": "2",
      "key": "x-envoy-upstream-service-time"
    },
    {
      "value": "nosniff",
      "key": "x-content-type-options"
    },
    {
      "value": "738d3502eba0a6ac-GRU",
      "key": "cf-ray"
    },
    {
      "value": "Origin",
      "key": "Vary"
    }
  ],
  "responseLength": 0,
  "requestLength": 0,
  "duration": 170
}
arthurgeron-work commented 2 years ago

We fixed this by adjusting our transcoder in the back end, not sure if everyone agrees that the player should respect redirection or not so I'll leave this open.

maxstoller commented 2 years ago

Hi @arthurgeron-work, thanks for reporting. We will discuss this behavior internally. Glad you were able to figure out a workaround in the meantime.

alexmdodge commented 2 years ago

@arthurgeron-work to help with our investigation, do you know if the previous package (react-native-aws-ivs-player) that worked for you was a previous version of this repository? Or is it another package on GitHub?

alexmdodge commented 2 years ago

After some internal investigation, re-labelling as a feature request as we do not support this path with the current wrapper implementation. We're evaluating where to put this in our roadmap.

arthurgeron-work commented 2 years ago

@arthurgeron-work to help with our investigation, do you know if the previous package (react-native-aws-ivs-player) that worked for you was a previous version of this repository? Or is it another package on GitHub?

No it wasn't a previous version of this repository! It was developed by a independent dev that used AWS native player with a React Native Wrapping Layer, this is the link to the repo