From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stream data from labview to browser

Dear NI Guru's

 

I have a Labview .exe file and I would like to be able for customers to build their own graphical interpretation of the results in a webbrowser of their choice without NI componenets installed on the computer - read only, no remote control. (I've all ready implemented the NI webserver in my program and it broadcasts a static webpage with updates, but a number of our customers need more customized approaches or merging of data into their existing systems)

So basically what I would like to do, is to broadcast a .xml stream to a number of clients on the network. The clients will then use the xml stream to update digital displays, color bars and what have you, in response to changes in the xml stream while the labview .exe file is running. 

 

The amount of data is limited (roughly 5KB per update) and update should happen approx once a second. 

 

For now I've set up a very simple TCP server, that will open a connection when a client browser enters the appropiate ip:port in a browser. 

The mini server then starts to pass a cluster that I have flattened to an XML string once a second as a very preliminary test. 

browser will then start to display the data in the window, and add latest result to the bottom of the page. So far so good. 

However, when my webprogrammer starts to access the ip:port from he can not gain access to it - it appears that we run into somekind of safety measure in browsers along the lines of the same-origin policy.. 


I'm sure this is something all ready described, but I have simply not been able to find a proper answer on how to do this , so maybe I just need the proper vocabulary for what it is i'm searching for. 

 

Thank you in advance for your help. 

 

Windows 7, LV2012 latest patch. 

0 Kudos
Message 1 of 3
(2,290 Views)

There are three solutions. The first method is to use JSONP, the second method is to implement CORS and the third method is to host the web page at the same url as the data.

 

With JSONP, the browser is tricked into thinking it is loading a script, when in reality it is accessing data.


With CORS, the response headers are modified with the addition of access control headers. When a modern browser receives the access control headers it then allows the cross origin connection.

 

Access-Control-Allow-Origin: 10.0.0.2
I build web apps for LabVIEW
http://chrislarson.me
0 Kudos
Message 2 of 3
(2,265 Views)

Cheers Chris. 

I'll have a bit of studying to do on this one, and will be back if I fail to learn what needs to be learned:-)

 

0 Kudos
Message 3 of 3
(2,226 Views)