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

RTMP Status Listener not receiving RTMPConnection.Code.connectClosed Event when rtmpConnection.close() #671

Closed
allenlinli opened this issue Apr 26, 2020 · 4 comments

Comments

@allenlinli
Copy link
Contributor

allenlinli commented Apr 26, 2020

Describe the bug
Our RTMP status listening function is not getting a notification when we close the connection by rtmpConnection.close(). After reviewing #653 and #489, we do not know why our listener is not receiving the .connectClosed event.

Should the RTMPConnection.Code.connectClosed be called in such situation? If not, how can get the event when unpublish (close) the connection?

To Reproduce
Steps to reproduce the behavior:

  1. Comment (remove) the two lines in LiveViewController.swift
//rtmpConnection.removeEventListener(.rtmpStatus, selector: #selector(rtmpStatusHandler), observer: self)
//rtmpConnection.removeEventListener(.ioError, selector: #selector(rtmpErrorHandler), observer: self)
  1. Start the streaming by clicking the publish button (with preferred streamName and uri set up.)
  2. Stop the streaming by clicking the publish button again, which triggers rtmpConnection.close().
  3. Add a log in the function private func rtmpStatusHandler(_ notification: Notification).
  4. Notice no logs from rtmpStatusHandler

Expected behavior
rtmpStatusHandler is called with .connectClosed event; in this case, printing logs with event info.

Smartphone (please complete the following information):

Device: Real device iPhone X
OS: iOS 13.3
Version: HaishinKit (1.0.8) via CocoaPods

@allenlinli
Copy link
Contributor Author

I found the true reason should be our server does not send "NetStream.Connect.Closed" at all.
When I tried Facebook and Twitch, their server does not send it also, I wonder if sending "NetStream.Connect.Closed" is the standard procol?

@shogo4405
Copy link
Owner

shogo4405 commented May 3, 2020

Should the RTMPConnection.Code.connectClosed be called in such situation?

  • This status code raises disconnected by the server or turn off to WiFi.
    • if isDisconnected {
      let data: ASObject = (readyState == .handshakeDone) ?
      RTMPConnection.Code.connectClosed.data("") : RTMPConnection.Code.connectFailed.data("")
      events.append(Event(type: .rtmpStatus, bubbles: false, data: data))
      }
  • rtmpConnect.close() will not raise RTMPConnection.Code.connectClosed.

@allenlinli
Copy link
Contributor Author

Thank you so much. I understood.

@allenlinli
Copy link
Contributor Author

allenlinli commented May 4, 2020

Just a follow-up question. Then what's the proper way to get the callback for rtmpConnect.close()? Or we do not need the callback here at all?
Or should we raise RTMPConnection.Code.connectClosed when rtmpConnect.close()?

Here's an example in Action Script says:

Closes the connection that was opened locally or to the server and dispatches a netStatus event with a code property of NetConnection.Connect.Closed.

https://stackoverflow.com/questions/12049203/how-to-disconnect-an-rtmp-connection

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants