apivideo/api.video-reactnative-live-stream

[Feat]: Unpublish stream

Opened this issue ยท 29 comments

Version

2.0.0

Environment that reproduces the issue

Device iPhone xs max iOS 16.1

Use case description

Currently, the stop() method disconnects the stream but doesn't unpublish it from the server. How can we unpublish the stream?

Proposed solution

There should be a method to unpublish the stream from server as well.

Alternative solutions

No response

Hi,

I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?)

I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish.

Do you have the same issue with Android?

Hi,

I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?)

I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish.

Do you have the same issue with Android?

its FCUnpublish command. so what happen is if the stream gets unpublished then we get webhooks from rtmp server and if we close the stream (which is happening right now), webhooks won't be triggered and we have to wait for the timeout.
Can we get any method which can send FCUnpublish command

Hi,

I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?)

I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish.

Do you have the same issue with Android?

and yes it is same for android

Hi,
I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?)
I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish.
Do you have the same issue with Android?

its FCUnpublish command. so what happen is if the stream gets unpublished then we get webhooks from rtmp server and if we close the stream (which is happening right now), webhooks won't be triggered and we have to wait for the timeout. Can we get any method which can send FCUnpublish command

If the connection between the device and your server is lost, you won't get a FCUnpublish and your webhooks won't be triggered. In that case, you will face the same issue and there is nothing we can do about it.

Hi,
I guess you are talking about RTMP Command message. I don't think there is an official unpublish message. Which command message do you have in mind? (FCUnpublish, closeStream?)
I am just curious, what server do you use? Because if the connection is closed. There is no need to explicit unpublish.
Do you have the same issue with Android?

its FCUnpublish command. so what happen is if the stream gets unpublished then we get webhooks from rtmp server and if we close the stream (which is happening right now), webhooks won't be triggered and we have to wait for the timeout. Can we get any method which can send FCUnpublish command

If the connection between the device and your server is lost, you won't get a FCUnpublish and your webhooks won't be triggered. In that case, you will face the same issue and there is nothing we can do about it.

Yes that is ok, network outage may occur or peer disconnections. But that is usually rare.
But we need intentional control to unpublish our stream to complete the flow.
So a method would be good enough to unpublish stream along with existing closing stream

Hi,

For the implementation, I would rather like that stopStream calls FCUnpublish automatically instead of adding a specific method.

Hi,

For the implementation, I would rather like that stopStream calls FCUnpublish automatically instead of adding a specific method.

Yes, that would also work

I made a fix in the Android library.
Could you have a look at HaishinKit.swift (the iOS library)?

HaishinKit.swift

it checks FCUnpublish to send a call to server to unpublish
if let fcPublishName { connection.call("FCUnpublish", responder: nil, arguments: fcPublishName) }

Just to confirm. The argument in the FCUnpublish is going to be the provided StreamKey.
Is it what you expect?

Just to confirm. The argument in the FCUnpublish is going to be the provided StreamKey. Is it what you expect?

yes thats correct

Could you test the iOS version of the main branch?

Could you test the iOS version of the main branch?

sure, i have to test the example folder on the main branch?

Yes Please :)
You can run:

yarn && yarn example ios

Could you test the iOS version of the main branch?

so i've tested the main branch code, unfortunately its behaving the same way as before. I'm not getting any webhooks fired as it should be on the call of unpublish. The patchset is not working i guess.

hmm.
I can see FCUnpublish in Wireshark in the iOS example.
See:
Screenshot 2024-06-11 at 16 50 16

Hi there,

I was testing the main branch as well. The FCUnpublish() followed by closeStream() does not delete the stream properly from rtmp server. RTMP server reports connection closed by peerdue to closeStream() which is not the intended effect. In term of unpublishing the stream FCUnpublish command must be followed by deleteStream() command.

Here is the packet captured from OBS while starting and stopping.

image

Can you provide an updated build with above modification.

@ThibaultBee I guess that must be the issue, closeStream() is not killing the stream properly. can we replace or add deleteStream()?

Could you add an issue for this in HaishinKit?

FCUnpublish() followed by closeStream()

reported. Link

Could you test the android version on main branch?

Have you made any progress on the iOS part?

Have you made any progress on the iOS part?

it is in progress yet.

Have you made any progress on the iOS part?

@ThibaultBee PR is up for iOS haishinkit

Have you made any progress on the iOS part?

deleteStream PR is merged @ThibaultBee. You can integrate it in the package now.

Waiting for next HK release

Have you test the fix made for Android?

Release 2.0.1 is made with HK 1.9.3 that should fix this.

Could you test on 2.0.1?