pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.54k stars 772 forks source link

java.net.SocketTimeoutException: Read timed out #1229

Closed hayk-kerobyan closed 7 months ago

hayk-kerobyan commented 1 year ago

Getting "Connection failed. Error configure stream, Read time out" on Huawei P30 pro all the time, however works fine on Huawei P30 lite and on any pixel emulator. Can you have any idea what can be the reason? The url is an rtmp Mux Api generated url with the following structure: rtmp://global-live.mux.com:5222/app/$streamKey

Non-fatal Exception: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(SocketInputStream.java) at java.net.SocketInputStream.socketRead(SocketInputStream.java:119) at java.net.SocketInputStream.read(SocketInputStream.java:176) at java.net.SocketInputStream.read(SocketInputStream.java:144) at java.io.BufferedInputStream.fill(BufferedInputStream.java:248) at java.io.BufferedInputStream.read(BufferedInputStream.java:267) at com.pedro.rtmp.rtmp.Handshake.readS0(Handshake.kt:142) at com.pedro.rtmp.rtmp.Handshake.sendHandshake(Handshake.kt:83) at com.pedro.rtmp.rtmp.RtmpClient.establishConnection(RtmpClient.kt:291) at com.pedro.rtmp.rtmp.RtmpClient.connect$lambda$0(RtmpClient.kt:200) at com.pedro.rtmp.rtmp.RtmpClient.$r8$lambda$PuN16_1vGWJCxgkZVqBgLW0MYcE() at com.pedro.rtmp.rtmp.RtmpClient$$ExternalSyntheticLambda2.run(:2) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:929)

pedroSG94 commented 1 year ago

It is weird. This seems that you connect to the server but after send a request you never receive a response from the server and you get a timeout. This happens on the first request. Can you check in server side if you receive anything from that device? Also, check that you can ping to server (to make sure that you can send and receive something from it)

If all is working you can try this test: Create a TCP socket manually, send a byte and check that you receive something from the socket. You have the way i do it here: TCP socket: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtmp/src/main/java/com/pedro/rtmp/utils/socket/TcpSocket.kt First request send to socket (that fail in your case): https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtmp/src/main/java/com/pedro/rtmp/rtmp/Handshake.kt#L96 You can copy this classes and check where is the error