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

[Feat]: Unpublish stream #79

Open
talhatsk opened this issue May 15, 2024 · 29 comments
Open

[Feat]: Unpublish stream #79

talhatsk opened this issue May 15, 2024 · 29 comments
Labels
enhancement New feature or request
Milestone

Comments

@talhatsk
Copy link

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

@talhatsk talhatsk added the enhancement New feature or request label May 15, 2024
@ThibaultBee
Copy link
Member

ThibaultBee commented May 15, 2024

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?

@talhatsk
Copy link
Author

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

@talhatsk
Copy link
Author

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

@ThibaultBee
Copy link
Member

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.

@talhatsk
Copy link
Author

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

@ThibaultBee
Copy link
Member

Hi,

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

@talhatsk
Copy link
Author

Hi,

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

Yes, that would also work

@ThibaultBee
Copy link
Member

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

@ThibaultBee ThibaultBee added this to the v2.0.1 milestone May 23, 2024
@talhatsk
Copy link
Author

talhatsk commented May 23, 2024

HaishinKit.swift

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

@ThibaultBee
Copy link
Member

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

@talhatsk
Copy link
Author

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

yes thats correct

@ThibaultBee
Copy link
Member

Could you test the iOS version of the main branch?

@talhatsk
Copy link
Author

Could you test the iOS version of the main branch?

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

@ThibaultBee
Copy link
Member

Yes Please :)
You can run:

yarn && yarn example ios

@talhatsk
Copy link
Author

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.

@ThibaultBee
Copy link
Member

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

@xoraingroup
Copy link

xoraingroup commented Jun 12, 2024

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.

@talhatsk
Copy link
Author

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

@ThibaultBee
Copy link
Member

Could you add an issue for this in HaishinKit?

@talhatsk
Copy link
Author

FCUnpublish() followed by closeStream()

reported. Link

@ThibaultBee ThibaultBee removed this from the v2.0.1 milestone Jun 17, 2024
@ThibaultBee
Copy link
Member

Could you test the android version on main branch?

@ThibaultBee
Copy link
Member

Have you made any progress on the iOS part?

@talhatsk
Copy link
Author

Have you made any progress on the iOS part?

it is in progress yet.

@talhatsk
Copy link
Author

Have you made any progress on the iOS part?

@ThibaultBee PR is up for iOS haishinkit

@talhatsk
Copy link
Author

Have you made any progress on the iOS part?

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

@ThibaultBee
Copy link
Member

Waiting for next HK release

@ThibaultBee
Copy link
Member

Have you test the fix made for Android?

@ThibaultBee
Copy link
Member

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

@ThibaultBee
Copy link
Member

Could you test on 2.0.1?

@ThibaultBee ThibaultBee added this to the v2.0.1 milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants