Hi all,
I have been trying to implement SSE in LabView. I don't know if this is even possible, but it would be really awesome if it was.
So far, this is what I've done in my Web Service project:
![server.png server.png]()
And this is my implementation in the client side:
var urlSSE = 'http://127.0.0.1:8001/RIP/SSE';
// Register to the SSE:
var source = new EventSource(urlSSE);
// Manage SSE Events
source.onopen = function(e) {
// Connection was opened.
console.log('Open');
};
source.onmessage = function(e) {
console.log('data:'+e.data);
if (e.id == "CLOSE") {
console.log('Closing');
source.close();
}
};
When I look at the network traffic in my browser's console I can see that the SSE connection is recognized and established:![Browser.png Browser.png]()
However, as you can see from above, the SSE only receives the data one time, then the connection ends and, after the timeout (set to 1000 miliseconds in the Vi), the client makes a new connection. This is happening, I guess, because the web service Vi is only executed once per each client request.
What I would like to obtain is a constant flow of data from the LabView server to the client, without having to ask for data from the client. It looks like I'm really close, actually. I would just need to keep the Vi running, particularly the Write Response.vi and the Flush Output.vi. I tried to put those inside a while loop but this didn't work.
Does anyone know how could I do this?
Thanks!