-
-
Notifications
You must be signed in to change notification settings - Fork 618
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
Reconnection from WiFi to 4G always results in lower transfer speed #1291
Comments
Unfortunately, I couldn't reproduce it in my environment, so I'm having difficulty finding a solution. I'm considering trying it in a different environment. How about others? |
I am still able to reliably reproduce this issue. In my case, I don't think I'm seeing any transfer speed at all after the reconnect. In order to work around this problem, I have had to implement my own reconnect strategy. In my implementation, when a disconnect happens, but then connectivity is restored, in order to successfully reconnect I am forced to perform the following:
Following this pattern, I am able to reliably reconnect and keep data flowing from the client to server. However this is not ideal, as nilling out the RTMPStream and RTMPConnection objects means I am not able to keep local recording active through a disconnection event. Ideally I would like to keep an uninterrupted local recording that runs even while a disconnect/reconnect of the RTMP stream occurs. If I instead attempt to connect and publish again on the same RTMPConnection and RTMPStream objects (the same way the HaishinKit example project handles reconnects), I will run into the bug as described by this thread. HaishinKit will log In my testing, the repro path I follow involves a phone that is connected to both cellular (typically 5G) as well as Wifi. If I start the broadcast, then shortly after that open control center and disable wifi, the bug is noticed pretty much immediately. I've also tested by walking out of range of the Wifi signal. The phone is still connected through cellular, and HaishinKit will very quickly log that the following connection was a success, but no data gets sent. However, if I perform another test in which I keep the phone in airplane mode with no cellular connection, and I simply disable and re-enable wifi, it seems the reconnect can work successfully in that case. The issue seems to be something specific about switching between wifi and cellular, which seems to align with the issue as described in this GitHub issue post. I have attached a log file from a test I ran on the haishin kit example project. In the test I included the Please let me know if there are any other details I can provide, or any additional tests I can perform on my environment with this reliable repro path to gain further insight. I would love to find a resolution for this issue so that I can support local recording throughout a disconnection/reconnection event. Thank you |
I have a hypothesis regarding this issue. I suspect that reusing the Socket instance might be causing some problem. Can you reproduce the issue with the following commit as well? There is a feature to output detailed logs for the Network framework. Please provide the logs using the following branch: You can see the logs like this.
|
I've tested the In my test, I ran the Example iOS + SwiftUI project on an iPhone 15 Pro Max on iOS 17.5.1. Logs from that attempt are here: haishinKit-swiftUI-demo-trace-network-framework-wifi-to-cellular.txt I then tested haishinKit-network-logging-wifi-to-cellular.txt In both tests, I did include the Near the end of both log files we see a repeating line: Please let me know if there are any additional tests I can perform to help diagnose the issue. Thank you |
@jhays CONNECT
RECONNECT
HaishinKit expects a response from the server to establish the Publish. Since there is no response from the server, it remains in an Idle state, as seen in the logs. Due to the lack of server response, the client cannot determine whether to continue sending data. It's natural that currentBytesOutPerSecond = 0 since no data is being sent from the client. CauseIt's likely that the server is attempting to reconnect at a time when it hasn't detected the client's communication interruption. Due to improper handling of this situation, it remains in an Idle state. In cases like nginx + rtmp module, errors like NetStream.Publish.BadName might be returned. SolutionsSolution 1
Solution 2
Solution 3
|
Thank you for the info. |
@mkrn
CONNECT
RECONNECT
|
Describe the bug
I tested these scenarios:
To Reproduce
In SwiftUI Example app.
(Same issue if you walk out of WiFi range)
Delegate to debug:
Expected behavior
After switching or loosing WiFi app should reconnect just as well
Version
main
Smartphone info.
iPhone 13 Pro
iOS 16, 17
Additional context
No response
Screenshots
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: