LabVIEW Web Development Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI Web Server multithread

Solved!
Go to solution

Is there a way to setup the NI Web Server to run a .vi in multiple threads when called multiple times simultaneously? This was/is possible in the NI Application Web Server, but due to the dependency on Silverlight to configure the Application Web Server we are migrating.

 

Thanks

 

M

0 Kudos
Message 1 of 7
(2,864 Views)

Hello, NI Web Server should have the same capability to run multiple HTTP method VIs and multiple clones of reentrant VIs in parallel as the NI Application Web Server. Could you verify that your HTTP method VI and any long-running subVIs that it calls are configured to be reentrant?

0 Kudos
Message 2 of 7
(2,806 Views)

Thanks for the reply, I am looking through the various VIs now and will respond once I verify.

 

One additional question on the NI web server: Is there functionality with the NI web server to create sessions and retrieve the session ID as was done in the Application Web Server?  The VIs for the application web serer will not execute when used under the NI web server. 

 

Thanks

 

M

0 Kudos
Message 3 of 7
(2,797 Views)

Unfortunately, the session API is not available when publishing to NI Web Server. You may be able to implement similar functionality in your own web service using controls and indicators to generate your own "session ID" that clients can echo back. Or if you require it being automatic like the session palette, it would be possible to use the Set Header VI to generate your own cookie and read it back using the Read Request Variable VI on future requests.

0 Kudos
Message 4 of 7
(2,792 Views)

Any chance of a very basic example of the "Set Header VI to generate your own cookie and read it back using the Read Request Variable VI on future requests" answer?  I have having difficulty getting it to pass data in my trials.

 

M

0 Kudos
Message 5 of 7
(2,790 Views)
Solution
Accepted by topic author mlwarren

I attached a library and simple example web service for implementing a server-side session database similar to the functionality provided by the Application Web Server's session palette. Because it uses data value refnums, there's some extra complexity to ensure the refnums aren't auto-closed at the end of each request.

 

It can be simplified if you store all of the data within the cookie itself (generally, this would require your total data to be sufficiently small and have it be okay for the data to be sent back and forth every request). To do that, take a look at the included Get Session Cookie Info.vi for how to compute what goes in the Set-Cookie header and Create Session.vi for actually sending the header, and Get Cookie Value.vi for how to read back the value from the Cookie header.

0 Kudos
Message 6 of 7
(2,769 Views)

Thanks, I had found a similar solution using cookies and global variables but I think this solution fixes one of my multi-thread issues.

0 Kudos
Message 7 of 7
(2,668 Views)