From 68035544345bf9bb5ebdfe342002822783766caf Mon Sep 17 00:00:00 2001 From: Saxon Milton Date: Tue, 1 May 2018 05:40:41 +0930 Subject: [PATCH] fixing rtmp handshake error --- revid/Revid.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/revid/Revid.go b/revid/Revid.go index 14021837..43d34ead 100644 --- a/revid/Revid.go +++ b/revid/Revid.go @@ -73,6 +73,7 @@ const ( sendFailedDelay = 5 maxSendFailedErrorCount = 500 clipSizeThreshold = 11 + rtmpConnectionMaxTries = 5 ) // Log Types @@ -503,11 +504,17 @@ func (r *revid) setupOutputForFfmpegRtmp() error { // setupOutputForLibRtmp sets up rtmp output using the wrapper for the c based // librtmp library - makes connection and starts comms etc. -func (r *revid) setupOutputForLibRtmp() (err error) { - r.rtmpInst = rtmp.NewRTMPSession(r.config.RtmpUrl, rtmpConnectionTimout) - err = r.rtmpInst.StartSession() - // go r.testRtmp(5000) - return +func (r *revid) setupOutputForLibRtmp() error { + for r.rtmpInst = rtmp.NewRTMPSession(r.config.RtmpUrl, rtmpConnectionTimout), + err = r.rtmpInst.StartSession(), noOfTries := 0; + err != nil && noOfTries < rtmpConnectionMaxTries; noOfTries++ + { + r.Log(Error, err.Error()) + r.Log(Info, "Trying to establish rtmp connection again!") + r.rtmpInst = rtmp.NewRTMPSession(r.config.RtmpUrl, rtmpConnectionTimout) + err = r.rtmpInst.StartSession() + } + return errors.New("Could not establish rtmp connection, check rtmp url!") } // setupOutputForFile sets up an output file to output data to