LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading SystemLink Tags in an NXG Web VI on a remote computer

I have a gviweb on NXG that can read SystemLink (Skyline) tags. (The tags are written to in a traditional LabVIEW program.)

 

I have built an application and I have hosted it on the NI Web server.  The web VI works when I go to a browser on the same computer that's hosting.  

 

I was trying to go to the Web VI on a browser on another device (my phone), but I get error 363650.  It looks like the error is related to CORS, but CORS is set to "Enable CORS for all origins (insecure)".  

 

If I create a web VI that does not utilize SystemLink tags, that works when I try to access it on my phone. 

 

Is another setting needed to enable outside devices to access the web VI with tags?

0 Kudos
Message 1 of 10
(3,240 Views)

Are you passing a URL to the Open Configuration.gvi?

 

If you did pass a URL and it is of the format "localhost:<someport>" then that url will only work on the machine the server is hosted on. The WebVI is trying to make a connection to the machine it is executing on (i.e. localhost). If you open the WebVI on a phone, it will try and make a connection to a server located on the phone itself (i.e. localhost) which there probably isn't one.

 

When the WebVI is running in the LabVIEW NXG editor (and therefore hosted on the LabVIEW NXG internal server), then you have to pass a url pointing to the NI Web Server (for example http://localhost:<someport>), a username, and a password to the Open Configuration VI. Also the NI Web Server has to have the CORS settings configured to allow communications from web apps on other servers. This is valuable for debugging and testing purposes, but it is not recommended to have the username and password in a production WebVI.

 

When the WebVI is built and hosted on the NI Web Server itself, then you do not need to pass the url (by default it will use the server that is hosting the WebVI) and you do not need to enable CORS. When the WebVI is hosted on the NI Web Server and talking to the Tag API of the NI Web Server then it is a same-origin request and CORS is not required. Also, if a user is also already logged in to the NI Web Server main page, then you can omit the username and password and the logged in account will be used instead.

 

Summary:

WebVI running (i.e. hosted) in the LabVIEW editor talking to tag api of NI Web Server:

Need URL with port of NI Web Server

Need an account with username and password

Need to enable CORS on NI Web Server

 

Built WebVI running (i.e. hosted) on the NI Web Server and talking to the tag api of the same NI Web Server:

Url can be blank

If the user already logged into the server then username and password can be blank

CORS does not need to be enabled on NI Web Server because no cross-origin hosting is happening


Milan
0 Kudos
Message 2 of 10
(3,224 Views)

I'm passing localhost to the open configuration VI, as in the attached picture.  For open tag, I'm passing <full computer name with MAC>.Write_Multiple_Tags_Client and then I concatenate Inside_Temp and Outside_Temp.  (I'm using the "Write Multiple Tags Client.vi" example.) 

 

I tried it without connecting localhost to the open configuration VI and disabling CORS, but I still get the same error when run on a browser on my phone.

 

When you say "If the user already logged into the server then username and password can be blank", does that mean that when running on my phone that I have to somehow log in from there?  Which VI is the "user"?  I tried it with those blank too and still got the same error.

0 Kudos
Message 3 of 10
(3,207 Views)

When you say "If the user already logged into the server then username and password can be blank", does that mean that when running on my phone that I have to somehow log in from there?  Which VI is the "user"?


The following is an animated gif that might make the workflow clearer:

 

niwebserverlogin.gif

 

The animated gif goes through the following steps:

  1. It shows a built WebVI hosted on the NI Web Server in the location specified in the Hosting a Web Application on the NI Web Server help topic.
    The WebVI has the following block diagram:
    mywebvi.PNG
  2. I visit the WebVI as hosted on the NI Web Server from a browser on the same machine as the NI Web Server. On my machine the NI Web Server was configured to use port 9090 and based on where I placed my files in the htdocs directory I visit http://localhost:9090/mywebvi in the web browser.
  3. When the WebVI runs I get a 401 unauthorized error because the diagram does not have a username and password and because I have not logged in yet with a user that has permission at the main page located at http://localhost:9090/
  4. I navigate to the NI Web Server main page at http://localhost:9090/ and login with a user that has permission to read tags
  5. I navigate back to the WebVI located at http://localhost:9090/mywebvi and observe that the WebVI is able to read the tags. I also navigate to the tag viewer app and confirm the tag at path "hello" has the value 6 that I observed in the WebVI.

I am able to use the above workflow from a mobile device that is on the same intranet by visiting the ip address of the computer. I visit the url <my-ip-address>:9090 to login and then visit <my-ip-address>:9090/mywebvi and the WebVI is able to read the tags.

 

My NI Web Server Configuration Remote tab looks like the following:niwebserverremoteconfig.png

 

Note that CORS does not need to be enabled as the WebVI is hosted on the NI Web Server itself. Also note that Allow remote connections from any client was enabled so that connections can be allowed from the network. The default of Block remote connections would prevent web browsers from other computers from accessing the WebVI.


Milan
Message 4 of 10
(3,200 Views)

When I go to localhost/#login, I only see the word "stop".  This also happens on my phone too.  Is there another setting that's needed?

0 Kudos
Message 5 of 10
(3,191 Views)

Using the bare url localhost/ implies a port of 80. Can you confirm that the NI Web Server Configuration pane is configured for port 80?

 

Example, the following shows my NI Web Server is configured for port 9090:

 

webserverport.PNG

 

I'm wondering if NI Web Server is running on port 80. If it is running on port 80 then I wonder if another server may be conflicting with it and that server is showing the page with the word "stop".

 


Milan
Message 6 of 10
(3,186 Views)

Yes, it's configured for port 80 as shown in the first attachment.

 

I also tried changing the port to 9090 as in your example, but I still get the same stop page.

 

Download All
0 Kudos
Message 7 of 10
(3,175 Views)

You probably need to install the "SystemLink WIF Web UI".  It typically gets installed if you install any SystemLink applications like the Tag Viewer, but if haven't installed anything else you may need to manually install it using the NI Package Manager.

 

Since it is an infrastructure component it isn't shown by default in NIPM, so you will need to enable the first 2 options under the settings gear icon in NI Package Manager.

Screen Shot 2019-06-27 at 7.09.32 PM.png

 

Then search for "SystemLink WIF" under on the Packages tab and install it.  Afterwards you should see it in the Installed tab like the following.

Screen Shot 2019-06-27 at 7.09.01 PM.png

Message 8 of 10
(3,157 Views)

It's already in the installed section in NI Package Manager, so I assume I have it.

0 Kudos
Message 9 of 10
(3,153 Views)

I decided to reinstall the web module and things work now.  Thanks for all your help.

Message 10 of 10
(3,134 Views)