Open captain-yoshi opened 1 year ago
TwinCAT doesn't expect TCP connections from localhost. Especially, when you use the same AMS NetId as Target and Sender address. So at least you have to use different AMS NetIds for the TwinCAT server (in outside Windows) and your ADS Client (inside WSL). Then it depends on WSL networking, which I have no clue about. If on the TwiNCAT side the connections looks like a normal remote host, then it should work as soon as you configured the AMS route correctly. If TwinCAT receives a TCP connection attempt from an IP it is listening itself I doubt it will work.
No luck with different AMS NetId... WSL networking has it's own considerations.
I think WSL1 gives you a localhost network only. WSL2 gives you a virtual network that you can configure but needs Hyper-V which is not compatible with TwinCAT in run-mode.
I did not try changing my TwinCAT Local NetId to localhost... Maybe that would work.
It works through VirtualBox and remotly, so really not a big issue for me. Thanks for the library ! Very handy 👍
I think the author of a nodejs ADS client figured out what's necessary for localhost communication - reservation of a port on the router. This has since been at least partially propagated to the rust client ads-rs (though I'm not sure if it cleared the reserved port after use). It should work for WSL1 with localhost networking, though WSL2 is a different story as you've noted.
Since this is technically possible over ADS, I wonder if it's something that might be accepted for Beckhoff's open source library here. Even some official acknowledgment/documentation of the underlying mechanism would be nice, too.
Links:
Is it possible to run the ADS Client on a windows subsystem linux (WSL) which communicates through the localhost ? FYI it works when installing the client on a remote PC using the same linux distribution as the WSL (Ubuntu 20.04).
Maybe related to #93 and #141.
ADS Route
Client Config
Running the Client Example
Wireshark Debug (loopback adapter) wireshark-capture.zip