From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

"Port limit exceeded" error on my MASS FLOW CONTROLLER

I have attached VI below for your reference. This VI  is for reading data continuously from my device by sending command continuously(see lower while loop in code) and for changing the setpoint value of device using write command (see upper while loop). I can do both the operation but after a while I am getting error "TCP Port open limit exceeded". Also when I am writing data(sending commands) my reading data is getting distorted for a moment(1 or 2 seconds).

 

0 Kudos
Message 1 of 30
(1,312 Views)

Hi d,

 


@doc_d wrote:

This VI  is for reading data continuously from my device by sending command continuously(see lower while loop in code) and for changing the setpoint value of device using write command (see upper while loop). I can do both the operation but after a while I am getting error "TCP Port open limit exceeded". Also when I am writing data(sending commands) my reading data is getting distorted for a moment(1 or 2 seconds).


Basically this is your fault…

 

Why do you need to open and close the TCP connection in most cases of the event structure in the UI handling loop?

 

Why do you need to open and close the TCP connection in each iteration of the lower loop?

Even more worse: why do you open a new TCP connection in each iteration of the lower loop, but only close the last reference? Why do you use a "default if unwired" tunnel to actively forget the TCP reference and not even being able to close it properly???

 

Open the TCP connection ONCE BEFORE both loop and close it ONCE AFTER both loops have finished!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 30
(1,311 Views)

Thank you so much. I will try to do this. 

0 Kudos
Message 3 of 30
(1,305 Views)

I made changes you told me now the problem is whenever I send command from upper loop my output strings are getting distorted.

I am attaching screenshots for reference here.

0 Kudos
Message 4 of 30
(1,267 Views)

That's because you are using the same channel to send your stuff...

 

In the original VI you provided the upper while loop was "fine", you open connection, send a command and close the connection and then wait until next command.

 

The bottom loop was problem, because you opened a new connection on each iteration without closing/properly closing it afterwards.

 

EDIT:

I also don't see the point in using notifiers only to stop the execution and nothing else. You already have a "stop" event case in the upper loop, use that instead of notifiers.

0 Kudos
Message 5 of 30
(1,259 Views)

Won't that create same error "open port limit exceeded" again? I read somewhere that the limit is 1048 times which means I can open my port 1048 times thus I can only send command 1048 times.

0 Kudos
Message 6 of 30
(1,252 Views)

In my main code I have -1 timeout in event case this results reading my value only once that's the reason I am using notifiers.

0 Kudos
Message 7 of 30
(1,251 Views)

Problem only occurs if you open a TCP connection and don't close it, so each time you open it a new ID will be used.

Usually with communication you open a connection once, at the start of execution and then close it at the end of execution. In your case this means you open a connection before you enter your lower while loop and close it after you exit it. Keep the reference to the connection untouched (you have an error case with "default if unwired" value, which will destroy the reference, instead just wire your reference through error case).

 

You have a stop case in your event, place a boolean T in it and wire it to upper while loop terminal, get rid of notifier.

 

I'm still not entirely clear why you need two loops, i'm sure you could just use one loop and use another TCP write function if you have anything in your command string.

0 Kudos
Message 8 of 30
(1,243 Views)

If I put tcp open connection outside my lower while loop then whenever  I am sending data my data from lower while loop is distorted. I tried different suggestions but they are not working.

0 Kudos
Message 9 of 30
(1,229 Views)

Here, try this.

0 Kudos
Message 10 of 30
(1,218 Views)