S7NetPlus / s7netplus

S7.NET+ -- A .NET library to connect to Siemens Step7 devices
MIT License
1.33k stars 588 forks source link

Connect via/over NAT #406

Open RegyRegy opened 3 years ago

RegyRegy commented 3 years ago

Hello, is there an option to connect to the S7 behind the router over NAT ? I think it should be possible by forwarding ports, but can we set connection port with S7.net ?

Regy

scamille commented 3 years ago

You can set the port with this constructor: https://github.com/S7NetPlus/s7netplus/blob/b475aee2e768f709e6b8f01084b176e53d43cd8c/S7.Net/PLC.cs#L144 when creating the PLC object.

Using a different port than 102 for S7NetPlus works fine, assuming your PLC can be reached through it.

RegyRegy commented 3 years ago

public Plc(CpuType cpu, string ip, int port, Int16 rack, Int16 slot)

What a shame I didn't notice that! Thank you @scamille ! It't time to test it and forward ports.

I will give a feedback later!