Monitor icecast using node.js - node.js

I've got a rather vague question, but I'm hoping for some help.
I have icecast installed on an unbuntu server, with two server blocks setup using nginx.
Icecast is set to stream on https://stream.domain.com:8443/stream
I have a node.js app running on https://app.domain.com
Is there a way to "listen" to the icecast domain/stream/port using node and start a function when the stream starts, and stop it when the stream stops?
I'm not hoping for a full solution, just clues to point me in the right direction! Thank you in advance.

Make a request to
https://stream.domain.com:8443/status-json.xsl
it will return a JSON status of the server, then see the "source" key in this JSON - not empty "source" will indicate that there is a source connected to the server and Icecast is broadcasting something.
That JSON also provides a lot of additional info you can also use.
Also a basic check is to try to connect to port 8443 - if connection is not happening in, say, 5 seconds - that will indicate that Icecast is completely down.

Related

Client browser webcam streaming to node server and back

I've been researching a lot on how to live stream frames coming from the camera on browser, to a node server. This server processes the image, and then is supposed to send the processed image back to the client. I was wondering what the best approach would be. I've seen solutions such as sending frames in chunks to the server, for the server to process. I've looked into webRTC, but came to the conclusion that this works more for client to client connections. Would a simple implementation such as using websockets, or using socket.io suffice?
You can use WebSockets. But, I'd not recommend it. I don't think you should drop WebRTC, yet. It's not just for client to client connections. You can use a MediaServer like Kurento or Jitsi to process your frames and return the output. I've seen Kurento samples for adding filters and stuff. You can build your own modules on how to process the frames. I'd recommend that you check the MediaServer and see if it fits your requirements. Use WebSockets only if you are sure that WebRTC doesn't work for you.

NodeJS request pipe

I'm struggling with a technical issue, and because of I'm pretty new on NodeJS world I think I don't have the proper good practise and tools to help me solve this.
Using the well known request module, I'm making a stream proxy from a remote server to the client. Almost everything is fine and working properly until a certain point, if there is too much requests at the same time the server does no longer respond. Actualy it does get the client request but is unable to go through the stream process and serve the content.
What I'm currently doing:
Creating a server with http module with http.createServer
Getting remote url from a php script using exec
Instanciate the stream
How I did it:
http://pastebin.com/a2ZX5nRr
I tried to investigate on the pooling stuff and did not understand everything, same thing the pool maxSocket was recently added, but did not helped me. I was also seting before the http.globalAgent to infinity, but I read that this was no longer limited in nodeJS from a while, so it does not help.
See here: https://nodejs.org/api/http.html#http_http_globalagent
I also read this: Nodejs Max Socket Pooling Settings but I'm wondering what is the difference between a custom agent and the global one.
I believed that it could come from the server but I tested it on a very small one and a bigger one and it was not coming from there. I think it definitely coming from my app that has to be better designed. Indeed each time I'm restarting the app instance it works again. Also if I'm starting a fork of the server meanwhile the other is not serving anything on another port it will work. So it might not be about ressources.
Do you have any clue, tools or something that may help me to understand and debug what is going on?
NPM Module that can help handle stream properly:
https://www.npmjs.com/package/pump
I made few tests, and I think I've found what I was looking for. The unpipe things more info here:
https://nodejs.org/api/stream.html#stream_readable_unpipe_destination
Can see and read this too, it leads me to understand few things about pipe remaining open when target failed or something:
http://www.bennadel.com/blog/2679-how-error-events-affect-piped-streams-in-node-js.htm
So what I've done, i'm currently unpiping pipes when stream's end event is fired. However I guess you can make this in different ways, it depends on how you want to handle the thing but you may unpipe also on error from source/target.
Edit: I still have issues, it seams that the stream is now unpiping when it does not have too. I'll have to doubile check this.

apache storm into node js

I am currently developing as system from using storm. Data will come in from a kafka spout to a few bolt the the exit will be to a botl which sets a tcp connection to a NodeJs server application.
There is no problem when testing with low input of data. The problem arises when I test it with a large amount of data which the stream seems to be unstable.
I tried two ways to set the connection: Setting the connection only once and setting the connection and close once done. When I set the connection once the stream is coming in so fast into my NodeJs application the data got messed up and hit a data format error.
Opening and closing a connection makes the stream into NodeJs really unstable, it is ok the first few kb but after a while it stop the stream the flood stop and flood thr stream.
I'm just wondering: is there is any other way other then setting a tcp connection from storm to NodeJs or is there a way to make a connection once to NodeJs and make the message que. I'm running out of ideas any help on this issue?

Receiving Leap data from WebSocket server to Unity3D directly

I try to make connection between Leap Motion and mobile devices in Unity3D, via node.js.
Here are two examples I found online using node.js, this and this.
Now, I have successfully receive data from Leap Motion in this procedure:
Receiving JSON-formatted messages from "localhost:6437" in node.js
Parsing and Writing received data on another port (I use "localhost:8000") in node.js
Reading stream from port: 8000 in Unity3D
However, I wonder if it's possible to receive data DIRECTLY from "localhost:6437"? then maybe node.js is not needed.
I have tried to write in C# using TcpClient, but when I check "NetworkStream.DataAvailable", it returns false.
Thanks for your help.
For that you would need a WebSocket client, not a TCP client.

Shoutcast 1.9.9beta protocol

My app is able to stream Shoutcast stations, however today I found out that some of the stations use server version 1.9.9beta and my app can't start streaming them, it just fetched header information. There must be an important change between previous server versions. Does anyone aware of this change?
1.9.9beta server cannot handle "Range" header. This is a bug on the server.

Resources