RTMP connection disconnects when mobile Hotstop with low internet connection(500-1000kpbs)
Hi,
RTMP connection completely disconnects with low internet conditions.
Video settings: Width : 1280 Height: 720 FPS:30
H264,ACC codecs
library version : 2.5.5
Hello,
How are you doing to limit the bandwidth?
Hi @pedroSG94
we are testing with different distance of hotspot but when network speed reaches(500-1000kpbs) RTMP connection is disconnected.Internet connection is low but not disconnected.
This occurs only with 4g speeds or low internet hotspots.
Thanks
It is really difficult to say because I don't have a way to reproduce it. You can try use java socket to check if you have any change, but normally, if the stream disconnect using RTMP it is because you are losing the connection to the server. Maybe only 1 second but if the library fail to send packets because the connection is lost. The stream is disconnected.
Can you guide me a way to reproduce your case?
Hi @pedroSG94
Getting socket Time out Exception in below method when using low 4g mobile Hotspot (Not Wifi Hotspot)
Class : RtmpSender
override suspend fun onRun() { while (scope.isActive && running) { val error = runCatching { val mediaFrame = runInterruptible { queue.take() } getFlvPacket(mediaFrame) { flvPacket -> var size = 0 if (flvPacket.type == FlvType.VIDEO) { videoFramesSent++ socket?.let { socket -> size = commandsManager.sendVideoPacket(flvPacket, socket) if (isEnableLogs) { Log.i(TAG, "wrote Video packet, size $size") } } } else { audioFramesSent++ socket?.let { socket -> size = commandsManager.sendAudioPacket(flvPacket, socket) if (isEnableLogs) { Log.i(TAG, "wrote Audio packet, size $size") } } } bytesSend += size } }.exceptionOrNull() if (error != null) { onMainThread { connectChecker.onConnectionFailed("Error send packet, ${error.validMessage()}") } Log.e(TAG, "send error: ", error) running = false return } } }
Can we add timeout for RtmpSocket connection???
Thanks.
It is really difficult to say because I don't have a way to reproduce it. You can try use java socket to check if you have any change, but normally, if the stream disconnect using RTMP it is because you are losing the connection to the server. Maybe only 1 second but if the library fail to send packets because the connection is lost. The stream is disconnected.
Can you guide me a way to reproduce your case?
Hi
To Reproduce above issue Please connect 4G phone with SIM internet ON and place at particulat distance when Internet speed reaches with range of (500-1500kpbs).
Cant find any tool to mimic 4g Sim Hotspot.
Thanks.
Hi @pedroSG94,
Please find the github link for RTMP streaming comparison of both library Rootencoder and Simple RTMP.
Link: https://github.com/penmatsa/RTMPSample
When using low networking 4G Hotspot Rootencoder disconnects sharply but Simple RTMP just wait to connection to stabilize.
Thanks
Ok, the problem is that in Simple RTMP you haven't a timeout. In this library the timeout is 5s: https://github.com/pedroSG94/RootEncoder/blob/master/common/src/main/java/com/pedro/common/socket/base/StreamSocket.kt#L31 I can create a method to change the timeout in the socket
Hi @pedroSG94 ,
Comparing socket code for both library we found same timeout(5000),we think its not timeout made the difference.
Please find the attchments below
Simple RTMP
RootEncoder
Thanks.
It is not the same, only connect method has timeout in simple rtmp In my case I have timeout in write and read commands too
Hi @pedroSG94,
please point to class for custom timeouts in write and read commands.
Adding custom timeout helps use for low internet conditions.
Thanks
Hello,
I already did a commit for it to master. You can do it using this code:
genericStream.getStreamClient().setSocketTimeout(5000L)
Hi @pedroSG94,
Thanks for the support, will try with above code line.
Thank You