question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reconnect does not work properly (or i doing something wrong)

See original GitHub issue

Hello!

I am working on stream stability, because at moment it very unstable, and causes crashes and disconnects. I connect to stream by VLC player for tests. So i find your methods for retry added it in ConnectCheckerRtmp callbacks:

override fun onConnectionFailedRtmp(reason: String?) {

        Log.e("TEST", "ON CONNECTION FAILED: $reason")
        try {
            if (rtmpCamera.shouldRetry(reason)) {
                rtmpCamera.reTry(5000)
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

But as i see, stream does not reconnect properly, here is a logs of work:

2019-11-09 10:03:09.391 24005-24005 E/TEST: ON SURFACE CREATED 2019-11-09 10:03:09.391 24005-24005 E/TEST: ON SURFACE CHANGED 2019-11-09 10:03:09.639 24005-24005 E/TEST: START STREAM!!! 2019-11-09 10:03:10.741 24005-24280 E/TEST: ON CONNECTION SUCCESS 2019-11-09 10:03:10.742 24005-24280 E/TEST: IS STREAMING? true 2019-11-09 10:03:14.308 24005-24363 E/TEST: ON CONNECTION SUCCESS 2019-11-09 10:03:14.308 24005-24363 E/TEST: IS STREAMING? true 2019-11-09 10:03:15.027 24005-24285 E/TEST: ON CONNECTION FAILED: Error reading packet: Connection reset 2019-11-09 10:03:15.032 24005-24280 E/TEST: ON CONNECTION FAILED: Error send packet: Broken pipe … 2019-11-09 10:03:15.111 24005-24285 E/TEST: ON CONNECTION FAILED: Error reading packet: Connection reset 2019-11-09 10:03:15.186 24005-24285 E/TEST: ON CONNECTION FAILED: Error reading packet: Connection reset

And then crashes: 2019-11-09 10:03:16.145 24005-24285 E/RtmpConnection: Caught SocketException while reading/decoding packet, shutting down: Connection reset

read: unexpected EOF!

Another scenario is when looks like all normal, but in fact a cant connect to stream with VLC player after reconnection. At start of streaming player shows stream, after reconnect player cant connect, but in logs i see, that stream reconnected:

2019-11-09 10:10:25.706 26093-26093 E/TEST: ON SURFACE CREATED 2019-11-09 10:10:25.706 26093-26093 E/TEST: ON SURFACE CHANGED 2019-11-09 10:10:25.888 26093-26093 E/TEST: START STREAM!!! 2019-11-09 10:10:26.893 26093-26354 E/TEST: ON CONNECTION SUCCESS 2019-11-09 10:10:26.893 26093-26354 E/TEST: IS STREAMING? true 2019-11-09 10:10:30.650 26093-26439 E/TEST: ON CONNECTION SUCCESS 2019-11-09 10:10:30.650 26093-26439 E/TEST: IS STREAMING? true 2019-11-09 10:10:31.864 26093-26354 E/TEST: ON CONNECTION FAILED: Error send packet: Broken pipe 2019-11-09 10:10:37.439 26093-26467 E/TEST: ON CONNECTION SUCCESS 2019-11-09 10:10:37.439 26093-26467 E/TEST: IS STREAMING? true

And the last issue is - when i disconnect wifi on phone, stream cause crash with stack trace:

2019-11-09 10:11:53.670 26093-26708 E/RtmpConnection: Shutdown socket java.io.IOException: shutdown failed: ENOTCONN (Transport endpoint is not connected) at java.net.PlainSocketImpl.socketShutdown(PlainSocketImpl.java:267) at java.net.AbstractPlainSocketImpl.shutdownInput(AbstractPlainSocketImpl.java:582) at java.net.Socket.shutdownInput(Socket.java:1589) at com.github.faucamp.simplertmp.io.RtmpConnection.shutdown(RtmpConnection.java:401) at com.github.faucamp.simplertmp.io.RtmpConnection.close(RtmpConnection.java:381) at com.github.faucamp.simplertmp.DefaultRtmpPublisher.close(DefaultRtmpPublisher.java:31) at net.ossrs.rtmp.SrsFlvMuxer.disconnect(SrsFlvMuxer.java:172) at net.ossrs.rtmp.SrsFlvMuxer.access$1000(SrsFlvMuxer.java:48) at net.ossrs.rtmp.SrsFlvMuxer$3.run(SrsFlvMuxer.java:319) at java.lang.Thread.run(Thread.java:764) Caused by: android.system.ErrnoException: shutdown failed: ENOTCONN (Transport endpoint is not connected) at libcore.io.Linux.shutdown(Native Method) at libcore.io.ForwardingOs.shutdown(ForwardingOs.java:178) at java.net.PlainSocketImpl.socketShutdown(PlainSocketImpl.java:265) at java.net.AbstractPlainSocketImpl.shutdownInput(AbstractPlainSocketImpl.java:582)  at java.net.Socket.shutdownInput(Socket.java:1589)  at com.github.faucamp.simplertmp.io.RtmpConnection.shutdown(RtmpConnection.java:401)  at com.github.faucamp.simplertmp.io.RtmpConnection.close(RtmpConnection.java:381)  at com.github.faucamp.simplertmp.DefaultRtmpPublisher.close(DefaultRtmpPublisher.java:31)  at net.ossrs.rtmp.SrsFlvMuxer.disconnect(SrsFlvMuxer.java:172)  at net.ossrs.rtmp.SrsFlvMuxer.access$1000(SrsFlvMuxer.java:48)  at net.ossrs.rtmp.SrsFlvMuxer$3.run(SrsFlvMuxer.java:319)  at java.lang.Thread.run(Thread.java:764)

Can you give me some recomendations what i need to do for making more stable and dont crashable streaming? I am already forked your lib for needed modifications.

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Radcat501commented, Nov 11, 2019

Looks like i found problem:

rtmpCamera = RtmpCamera1(cameraSurface, this)

rtmpCamera.setReTries(reconnectionRetries)
rtmpCamera.reConnect(reconnectionDelay)

I am added this lines in camera initialization, and this causes stream falling after it starts.

0reactions
Radcat501commented, Nov 11, 2019

And i found problem with crash after wifi disabling - you was right, it caused by my http client which dont has error handling, so it crashing without internet.

Thanks a lot for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix a "Reconnect me" error - Android - Chromecast Help
To reboot, unplug the Wi-Fi router. Leave it unplugged for 2 minutes before you plug it back in.
Read more >
15 Proven Techniques To Reconnect And Rebuild A Broken ...
1. Go At It With An Open Heart And Mind · 2. Don't Find Excuses, Just Reach Out · 3. Set A Daily...
Read more >
We Don't Just Need to Connect — We Need to Reconnect
Even when we decide we want to reconnect, we're often unsure about how to do it.
Read more >
No Internet Connection? How to Troubleshoot Internet Issues
Restart your modem, router, and device​​ Restarting your modem and router should be the first thing you do when encountering an internet signal ......
Read more >
3 Steps to Reconnect When You Feel Disconnected From ...
The #1 thing couples fight about is not money or in-laws or sex. According to Dr. Gottman, most arguments in relationships are about...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found