gabek / node-internet-radio

Node.js module to get Now Playing information from an internet radio stream.
MIT License
49 stars 19 forks source link

Module times out on live365 streams #19

Closed kaigem closed 4 years ago

kaigem commented 4 years ago

Hello,

We've been having trouble with a few of our affiliates who stream on live365. The node-internet-radio module times out on retrieving the metadata for these streams. The module attempts the icystream method for these streams.

Thanks for looking into this!

-Kaigem

gabek commented 4 years ago

Hey there! Could you provide an example stream URL that you're using for testing?

kaigem commented 4 years ago

Further Rock Radio - http://streaming.live365.com/a81821

This particular station worked for us in the past. They recently switched platforms to live365 and we can no longer obtain their metadata.

gabek commented 4 years ago

In the mean time it looks like the actual URL to the audio, http://ais-edge07-live365-dal02.cdnstream.com/a81821, is working ok:

{
  title: "Hellacopters, the - 03 - Sometimes I Don't Know",
  fetchsource: 'STREAM',
  headers: {
    'icy-br': '128',
    'icy-pub': '0',
    'icy-description': 'Further Rock Radio',
    'icy-genre': 'TBD',
    'icy-metaint': '8192',
    'icy-name': 'Further Rock Radio',
    'content-type': 'audio/mpeg'
  }
}
kaigem commented 4 years ago

The audio has indeed been working fine on our app. We just cannot get the metadata, which to our listeners is very frustrating. I will try using the URL above in our code to see if behaves differently than the browser-friendly URL. Thanks!

gabek commented 4 years ago

Ok, it's fixed in master. I'll get a release up to NPM after #18 gets cleared up.

kaigem commented 4 years ago

I downloaded the latest version of the plugin and we are still seeing problems with the aforementioned streams. Could you please explain, mechanically, what the plugin is doing?

gabek commented 4 years ago

By latest version, do you mean master? Or latest release? There has not been a release yet with this fix:

https://github.com/gabek/node-internet-radio/commit/f68094fe7a987852782b164e26c0dd302c998560

gabek commented 4 years ago

Version 0.2.1 has now been published to NPM. Please let me know if you still run into issues.

kaigem commented 4 years ago

We are still experiencing issues with our broadcasters that use live365. The error we are getting appears to be a timeout error

Error: Attempting to fetch station data via stream timed out. at Timeout. (/root/internetfm_server/node_modules/node-internet-radio/lib/icystream.js:20:7) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10)

gabek commented 4 years ago

The code has a hardcoded 5 second timeout. If I run the test against your stream and allow the test the 5 seconds as well I get a success. If you run this same test test/integration/test.js do you get the same results? It takes about 3 seconds to run.

../../node_modules/.bin/mocha --timeout 5000 test.js

image

kaigem commented 4 years ago

I performed the test on the Further stream and it works fine, although it does not spit out the full metadata like you have above. I just see this:

$ ../../node_modules/.bin/mocha --timeout 5000 test.js

Try all available methods and return a station object. √ Should have applicable properties. (2609ms)

1 passing (3s)

As long as it works though, it will be fine on our end.

What do you recommend we do to override the timeout?

gabek commented 4 years ago

Sorry about that, I added the spitting out of the full metadata just for my local testing so I could see what's coming out.

I could add an additional parameter to customize the timeout. Though 5 seconds is a pretty long time, but I see no reason not to let you change it if you have reasons to. I'll get to that this week.

kaigem commented 4 years ago

I'm.... I"m not sure the timeout is the problem. The station passes your diagnostic test in less than 5 seconds. Something else is going wrong when it runs on the live app though. That is why I was hoping to see the raw metadata, I wanted to see how it was processed. Unfortunately we can't even get the module to identify the stream when we use it.

gabek commented 4 years ago

You can print out the metadata in the test if that's helpful to you just by adding a line in test/integration/test.js

-var testStream = "http://ice1.somafm.com/groovesalad-128.mp3";
+var testStream = "http://ais-edge07-live365-dal02.cdnstream.com/a81821";

main.getStationInfo(testStream, function (error, station) {
+      console.log(station)
       expect(station).to.exist;

I wish I had another suggestion of why when you run the same code in your actual app it's not working. Is something blocking something, making it take longer? I'd just try simplifying things as much as possible and just try running it just like the test does and adding back your other code to try to see what's going on.