LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW web service works in debug but not when published

Hi everyone,

 

I'm hoping you can offer some suggestions on this issue I'm having. Thanks in advance!

 

I have a LabVIEW web service which, in addition to its HTTP Method VIs, also has a startup VI that listens for communication over TCP from other programs I've written running on other computers. When I run the web service in debug mode (by right clicking and selecting Start) it works perfectly. I can send TCP packets to it from other computers and recieve responses. The problem is when I stop the debug mode and publish the web service, I can still view it from my browser and I can still send TCP packets from the same computer, but it doesn't work from other computers. They get a timeout error. Any idea how I can fix this?

0 Kudos
Message 1 of 8
(4,453 Views)

Here's an example project that shows the problem. If you run the web service in debug mode and go to another computer and try to send a TCP packet to the first computer on port 1024, it works and you'll get a response of "A". But if you publish the web service and try it again from another computer, it won't connect. It will, however, work in both cases if you try it from same computer.

0 Kudos
Message 2 of 8
(4,442 Views)

Hi prettypwnie,

 

I am thinking that maybe you are not using the right port. When you debug the application you are using some port and when publishing a different one. 

 

Give a read to this document, it explains some configuration settings you should mind. There is a section called Configured Web Application Server that it will take you to what port is being used for the published application.

 

http://zone.ni.com/reference/en-XX/help/371361L-01/lvdialog/web_server_config_options/

 

I don't know if you have already set this configuration properly, so let me us know.

0 Kudos
Message 3 of 8
(4,397 Views)

Hi, thanks for your reply. Sorry, I think I must not be explaining the problem right. I don't mean that the port for viewing the web page doesn't work. If I publish the webservice I can see my webpage by going to [server IP address]:8080/[WS name]/index.html and if it's in debug mode I can see it at the same, but with 8001 instead of 8080. But there is also some extra TCP communication in a startup VI in the web service that communicates between some other programs I wrote running on different computers, and that is what only works in debug mode. Sorry if I'm not using the right terminology. Is this just not somehing I'm supposed to be able to do? Is it some kind of security thing that is preventing the communication when published? Oh well, at least it works in debug mode...

0 Kudos
Message 4 of 8
(4,347 Views)

Hi prettypwnie,

 

I am not sure if it's a security issue, can you try to publish it in a different port? You could find out if your LAN has some security impediments in that port.

 

It depends on what are you referring to with "extra TCP communication". I've found a few resources you can check.

https://zone.ni.com/reference/en-XX/help/371361K-01/lvconcepts/ws_web_server/#debugging

https://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/ws_enable_web_server/

https://zone.ni.com/reference/en-XX/help/371361K-01/lvconcepts/ws_web_server/

0 Kudos
Message 5 of 8
(4,323 Views)

What I'm referring to by "extra TCP communication" is the code I have in startup.vi in the example project I posted. I've tried doing that on lots of different ports, none of them work.

 

I guess it seems like communicating to other computers from the webservice is just not allowed. So maybe if I want it to work I have to write a separate program to run on the same computer to receive those communications from the other computers and then send them to the web service. But that seems like a lot of extra work. I don't know if you have any other ideas?

0 Kudos
Message 6 of 8
(4,319 Views)

Hi prettypwnie,

 

I am thinking of the web service limitations, I am not sure if you are allowed to access the web service through several connections (seems logic). I think looking into the web services documentation you'd get a clue about it. Your idea seems like a good solution (lot of work though) but that way you'd avoid future communications problems.

0 Kudos
Message 7 of 8
(4,304 Views)

Are the TCP functions in the Startup VI returning any errors?

 

Adding some logging information may help narrow down the problem. Check that the TCP Listeners are not giving errors by manually logging errors to a file, etc.

 

For some quick projects I have found it helpful to write errors into a shared variable and then add an endpoint that dumps the shared variable into a page to inspect, ie at /myWebService/errors.

 

You can also do normal Remote Debugging with LabVIEW Web Services but I find having a log file or endpoint listing errors around pretty useful.

 

Edit: Another handy TCP debugging function to run from the command line is 'netstat -a -b' which will tell you what application is using each open port. The list might be long so saving the ouput to a file to read may be helpful, ie 'netstat -a -b > C:\netstat_results.txt'


Milan
Message 8 of 8
(4,277 Views)