Page 1 of 1

Closing connection: NetStream.Failed

PostPosted: Mon Aug 18, 2014 3:38 pm
by haamro
Hello there, I am building groovy, that fetches rtmp and sends it to serviio
but I am getting the following error.

From serviio.log
  Code:
libswscale      2.  3.100 /  2.  3.100
libswresample   0. 17.102 /  0. 17.102
libpostproc    52.  3.100 / 52.  3.100
Closing connection: NetStream.Failed
rtmp://xxxxxxxxxxx   playpath=sportstime?token=GltZT0yMDE0MDgxODE1MT live=1 buffer=100000000: Unknown error occurred


This is the output of eclipse:
  Code:
ContentURLContainer [fileType=VIDEO, contentUrl=rtmp://xxxxxxxxxxx   playpath=sportstime?token=GltZT0yMDE0MDgxODE1MT live=1, thumbnailUrl=http://xxx/tv.jpg, expiresImmediately=true, cacheKey=xx_xxTV, live=true, ]

Please note:
1. token only works once
2. I know it does not have swfURL and pageURL but it works, when I paste it directly to console->live stream. It says the URL is valid.
3. I tried ffmpeg.exe -i "rtmp://xxxxxxxxxxx playpath=sportstime?token=GltZT0yMDE0MDgxODE1MT live=1"

am I missing something ? why would it work on console when I add it as live stream (at least it says the link is valid) but not work with actual groovy ?

thx

Re: Closing connection: NetStream.Failed

PostPosted: Tue Aug 19, 2014 6:06 pm
by zip
If the token only works once, it might be a problem. As Serviio will use the URL to fetch metadata before you even attempt to play it. Alternatively you could set expiresImmediately to true, which will cause the groovy code to be called again just before playback - but I think that is only taken into account for live streams (not sure if yours is)

Re: Closing connection: NetStream.Failed

PostPosted: Tue Aug 19, 2014 7:56 pm
by jhb50
I think that is only taken into account for live streams

That is correct but Nothing in the spec says expires immediately only applies to live streams.
I in fact have non-live streams where the "key" changes over time and requires expires immediately to re-extract at play time.
I have raised a ticket to fix that by making expires immediately apply to all stream types.

I tried ffmpeg.exe

You need to get it to work on the command line first. Try ffplay -i "rtmp......",
then if it works run ffmpeg.exe -i "rtmp...." from the command line and post the output here

Re: Closing connection: NetStream.Failed

PostPosted: Tue Aug 19, 2014 11:42 pm
by haamro
Thanx for the reply

1. it is a live stream
2. expiresImmediately is set to true as you can see on eclipse output
3. It does work on ffplay
4. please find the attached image
Image

my XBMC and WDTV does shows the link, but not able to play.

Re: Closing connection: NetStream.Failed

PostPosted: Wed Aug 20, 2014 12:01 am
by jhb50
From serviio.log
Code:
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Closing connection: NetStream.Failed
rtmp://xxxxxxxxxxx playpath=sportstime?token=GltZT0yMDE0MDgxODE1MT live=1 buffer=100000000: Unknown error occurred

In my experience this is not from the log which never displays the ffmpeg details.
You are simply changing and hiding too much data to be able to help you.

Re: Closing connection: NetStream.Failed

PostPosted: Wed Aug 20, 2014 11:02 am
by zip
you have to check the detailed log to see how many times and when the ffmpeg command is called, and with which token. I assume it's called twice with the same token somewhere along the process.

Re: Closing connection: NetStream.Failed

PostPosted: Thu Aug 21, 2014 12:31 am
by haamro
I did the detailed log. And to my surprise looks like the token is not being refreshed and the same token is being used each time. But when I run the script with Eclipse different Token is generated each time.
Looks like serviio is not respecting expiresImmediately=true

Re: Closing connection: NetStream.Failed

PostPosted: Thu Aug 21, 2014 8:22 am
by zip
did you see at any point the plugin being invoked again due to expiresImmediately?

Re: Closing connection: NetStream.Failed

PostPosted: Thu Aug 21, 2014 11:04 pm
by haamro
Well I am not quite sure how to check that, but the detailed logs shows the same token everywhere. I think this is the reason why the video is not opening.


  Code:
2014-08-21 18:29:25,464 DEBUG [FeedItemUrlExtractor] test.groovy: Staring video URL extraction for null
2014-08-21 18:29:25,464 DEBUG [FeedItemUrlExtractor] test.groovy: Finished extraction of url: ContentURLContainer [fileType=VIDEO, contentUrl=rtmp://xxxx/ playpath=sports?token=SAMETOKENEVERYTIME live=1 swfVfy=1, thumbnailUrl=http://image, expiresImmediately=true, cacheKey=TEST.COM_Channel1, live=true, ]
2014-08-21 18:29:25,464 DEBUG [VideoDeliveryEngine] Successfully set new URL for the feed item

The above log occurred twice ( 1 for adding and 1 while trying to play video I guess ) in the entire log, but the token is the same in both instances. I tried to play the video after 30 min and it is the same token :(

Also I noted, it shows as FeedItemUrlExtractor while my groovy uses WebResourceUrlExtractor.

I re-ran my groovy in eclipse and everytime it generates different token.

Re: Closing connection: NetStream.Failed

PostPosted: Fri Aug 22, 2014 1:51 am
by jhb50
I'm a little confused by your statement "I re-ran my groovy in eclipse and everytime it generates different token" implying that the expires immediately code ran there too.
AFAIK, the expires immediately logic is only within serviio and so when you test your groovy outside of serviio, only the 2 methods (WebResourceContainer extractItems and ContentURLContainer extractUrl) run, and with each test you will see a different token.
When you load your groovy in Serviio, the 2 methods will run, and when you play an item declared as expires immediately the second method will run again, and reextract the url to give you the token per your groovy code.
I just had the same problem and it turned out my groovy code was failing within Serviio without any notification causing the rextract to fail and the original cached url and token to be used. The way to fix that is to add log statements to your groovy at each step in order to identify and fix the point it fails. My groovy now works correctly, and I can also report that "expires immediately" works correctly for both live=true and live=false feed items, and so I have cancelled by bug report referenced earlier.

Re: Closing connection: NetStream.Failed

PostPosted: Fri Aug 22, 2014 11:41 am
by haamro
jhb50 wrote:I'm a little confused by your statement "I re-ran my groovy in eclipse and everytime it generates different token" implying that the expires immediately code ran there too.

No, it just means that my code is correct in extracting correct URL everytime. Eclipse has nothing to do with expiresImmediately

is my cacheKey a problem ? do I need to add token or URL to cachekey to make it unique ?

jhb50 wrote:The way to fix that is to add log statements to your groovy at each step in order to identify and fix the point it fails.

I will try this

Re: Closing connection: NetStream.Failed

PostPosted: Fri Aug 22, 2014 2:27 pm
by jhb50
is my cacheKey a problem ? do I need to add token or URL to cachekey to make it unique ?

No, its fine. The latest URL including the token will be cached under that key and used when you play it. If the key has your token added then a new key will be created with each extract. Both work but the latter will grow the cache for no good reason.
PS: As your first test add a log displaying the token just before the "return new ContentURLContainer" statement; update the groovy in Serviio; play the item. If the Debug log does not display the log at play time then the reextract failed before that point and the original token (which is displayed earlier in the log at the initial extract time)will be used, or if the log still shows the original token, then your extract logic is faulty.

Re: Closing connection: NetStream.Failed

PostPosted: Sat Aug 23, 2014 3:20 am
by haamro
As your first test add a log displaying the token just before the "return new ContentURLContainer" statement; update the groovy in Serviio; play the item. If the Debug log does not display the log at play time then the reextract failed before that point and the original token (which is displayed earlier in the log at the initial extract time)will be used, or if the log still shows the original token


I did that, and the debug log display the same token with each request. Looks like I am missing something here :(

then your extract logic is faulty.

Well, I run my Groovy in eclipse, and it pulls different token every time

I think this is more of a cache problem. Do i need to reset the variable to null before assigning the value ?

Re: Closing connection: NetStream.Failed

PostPosted: Sat Aug 23, 2014 2:35 pm
by jhb50
Well, I run my Groovy in eclipse, and it pulls different token every time

Of course it does because it only runs the first extract, never the re-extract at play time which only happens in serviio.
ie: your logic fails when re-extracting so you need to debug with log statements to see where the re-extract differs from the original extract.