illuminated-g / lv-levis-tcp

A lightweight TCP messaging library
MIT License
3 stars 1 forks source link

strange behavior on Linux #5

Open AntoineChalons opened 3 months ago

AntoineChalons commented 3 months ago

have you used this on Linux Desktop?

I've never had any issue on Windows or NI Linux RT, but when both the server and the client are on my Ubuntu 22 LTS VM I have very strange behavior, it's difficult to explain... Basically if I create a client and do open, the status will go 'connecting' and ""sometimes"" after a few seconds it will go to 'connected' even though I have not started the server, and I if I run the server after that of course it cannot connect. I ran tcpdump in the terminal to check the tcp traffic but there isn't any, quite confusing.

as a temporary work-around I did the following

this forces me to feed the local port in the client and the server, but at least now it works as I expect.

negentropicdev commented 3 months ago

I'll be looking into this. Checking of the local port is generally something you don't do like that so I'm curious what's causing the behavior you're seeing. It seems like there's some misunderstanding on how ports should work with TCP and the listener shouldn't be closed if it gets one bad connection. TCP listeners always listen on a specific port; it's how clients know what port to initiate the connection on. The local port on the server side should never match the local port used on the client side. During a TCP connection the server side gets assigned a random port to use for the continued data transfer and the listener port goes back to waiting for another connection which would then also end up on a separate port. I won't be accepting your PR as-is because of all of this and I'm surprised it's working for you. Seems more than likely to be a bug in LV TCP on linux desktop.

What version of LabVIEW are you using on Linux? I should have some time this weekend to get a linux vm running and check out this behavior.

AntoineChalons commented 3 months ago

Thank you for your reply I'm using LabVIEW 2020 SP1 Let me know if you want me to run tests on my VM

AntoineChalons commented 3 months ago

I ran a few tests on my Ubuntu VM

Launching 10 clients from port 34000 to 34009 (not launching any servers).

After a few seconds (~10s) all the clients on even ports are reporting a "Connected" status (34000, 34002, 34004, etc) and the client on odd ports (34001, 34003, etc) are reporting a "Connecting" status

Here's the VI I used launch multiple clients.zip

It seems to me that the issue is on my VM rather than a LV bug