Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RTMP 302, support RTMP 302 redirection. #369

Closed
winlinvip opened this issue May 16, 2015 · 21 comments
Closed

Support RTMP 302, support RTMP 302 redirection. #369

winlinvip opened this issue May 16, 2015 · 21 comments
Assignees
Labels
Feature It's a new feature. TransByAI Translated by AI/GPT.
Milestone

Comments

@winlinvip
Copy link
Member

winlinvip commented May 16, 2015

https://github.com/winlinvip/simple-rtmp-server/issues/92

If RTMP could support a 302 redirect, it would be more advantageous for CDN scheduling.
Wowza returns a reject, and then the player redirects:
http://developer.longtailvideo.com/trac/ticket/1876

Considering if it could be supported in NetConnection/NetStream, it would be more advantageous.

TRANS_BY_GPT3

@winlinvip winlinvip added the Feature It's a new feature. label May 16, 2015
@winlinvip winlinvip added this to the srs 3.0 release milestone May 16, 2015
@winlinvip winlinvip changed the title [功能增加] 支持RTMP 302重定向 Support RTMP 302, 支持RTMP 302重定向 Sep 17, 2015
@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

http://helpx.adobe.com/legacy/kb/rtmp-stream-redirect-implementation-open.html

OSMF says, it is also a reject returned by the server.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

http://www.adobe.com/cn/products/adobe-media-server-professional/features._sl_id-contentfilter_sl_featuredisplaytypes_sl_all.html
AMS says it is built-in support:
Server redirection
Automatically provide video players with new or alternate locations if content is missing using built-in redirection in RTMP similar to HTTP 302 redirection.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

Modify file: /opt/adobe/fms/conf/_defaultRoot_/Adaptor.xml














192.168.1.107:1935
:8080
:8443

Playback address: rtmp://192.168.1.129/live/livestream
Is it redirected to: rtmp://192.168.1.107:1935/live/livestream
Answer: No.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

http://www.wowza.com/forums/showthread.php?1945-RTMP-redirection
Implementation of Wowza. Return rejection.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

http://www.adobe.com/livedocs/flashmediaserver/3.0/hpdocs/help.html?content=00000251.html
Wowza is like FMS, both of which are actually implemented on players.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

sudo rm -f /opt/adobe/fms/applications/live/main.far
sudo vi /opt/adobe/fms/applications/live/main.asc
Input content as follows:

application.onConnect = function(client) {
    var tcUrl = "rtmp://192.168.1.107:1935/live";
    application.redirectConnection(client, tcUrl);
}

Playback URL: rtmp://192.168.1.129/live/livestream
Packet capture reveals rejection packet.
rtmp 302

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

sudo rm -f /opt/adobe/fms/applications/live/main.far
sudo vi /opt/adobe/fms/applications/live/main.asc
The input content is as follows:

application.onConnect = function(client) {
    var tcUrl = "rtmp://192.168.1.107:1935/live";
    application.redirectConnection(client, tcUrl);
}

Playback address: rtmp://192.168.1.129/live/livestream
Packet capture revealed a reject packet.
rtmp 302

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

SRS can actually consider supporting multi-processes with this approach.
As a solution,
the master process specifies multiple addresses and redirects to other ports.
This way, each process is completely independent, with high scalability and performance.
It is also extremely simple.

To be specific:

  1. Start a master SRS instance listening on port 1935.
  2. Start several edge SRS instances that connect back to the master SRS on ports 19350/19351, etc.
  3. Configure multiple redirects in the master SRS.
  4. When a player connects to the master SRS, it will be redirected to an edge SRS on the local machine using round-robin on ports 19350/19351, etc.
    With this structure, there is no need to modify any code, just make slight changes to achieve multi-processing.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

This way, you can use jwplayer or osmf, not limited to flowplayer, and it is also possible to achieve multiprocessing between multiple hierarchical nodes.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

And for other players, if they do not support redirection, they can be connected with parameters, so it can be compatible. For example, if supported, play: rtmp://xxxx/app?allow_redirect=true/xxxx. If not supported, play the default address. In this way, the client's modifications are minimal, just add an address on the webpage.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

Even with smaller modifications, as long as the domain name contains the term 'redirect' in rtmp://redirect-xxxx.xxx/xxx, it means that redirection is possible. Isn't that even more amazing?

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Sep 17, 2015

osmf, jwplayer, I have tested and they are supported. Other players are also mostly supported, but for those created by clients themselves, you need to handle that event, which is not too difficult. Unfortunately, it is not possible to assume that the client's player can be modified. You can use a flexible solution, as mentioned earlier, to differentiate whether redirect is supported in the URL, which is not a problem.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Jan 8, 2016

After the play, if RTMP 302 is sent, it is also valid.
srs_player can receive this packet and then process it to reconnect.
jwplayer can also handle it. Wireshark cannot parse it when capturing packets.

The best practice is that when the client receives RTMP 302, it should call the server's call and then redirect after 1 second.

media_conn.call("Redirected", null, evt.info.ex.redirect);

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Jan 8, 2016

Generally, it is rejected after the connection, but sometimes it is only known after playing, for example, knowing that the stream is on another server.

TRANS_BY_GPT3

@dongshen1126
Copy link

dongshen1126 commented Dec 2, 2016

Hello, I would like to ask if the feature of rtmp 302 redirection has been implemented in srs 3.0 version. Thank you.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Apr 14, 2017

You can check the submission time, it should have been implemented in SRS2 or 3.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Apr 14, 2017

Only the API implementation has been achieved, and no active mechanism for providing a 302 has been offered.

  1. If your Origin returns a 302 to the SRS edge, the edge supports it.
  2. If the server gives a 302 to the SRS player, it is also supported.
  3. SRS has a redirect API that you can call to return a 302 to the client.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Apr 14, 2017

@winlinvip
Copy link
Member Author

winlinvip commented Apr 14, 2017

Still need to configure files or policies to return RTMP 302 in some cases.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

Fixed in SRS3.

@winlinvip winlinvip changed the title Support RTMP 302, 支持RTMP 302重定向 Support RTMP 302, support RTMP 302 redirection. Jul 25, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature It's a new feature. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

2 participants