
yNos (Customer) asked a question.
Any better Ethernet interfaces in the pipeline?
We are running into a problem where we run out of sockets on the stock Ethernet interface, are there any others in the pipeline?
We are currently running:
arduinoOTA (2 listeners, the main listener and mDNS),
ftp ( 2 listeners, one on 21, one on a high port for xfers)
modbus (one socket per client, plus timeouts)
It would be nice if it would prune the closed connections faster, but I haven't quite figured out how to make that happen. For example, our SCADA system polls every 10 seconds, there are 4 sockets in close_wait that cannot answer another connection.
- Modbus service is unhappy!
- Socket#0:CLOSE_WAIT 502 D:192.168.24.46(53384) <- modbus
- Socket#1:SOCK_OPEN 65280 D:0.0.0.0(0) <- arduinoOTA
- Socket#2:SOCK_UDP 5353 D:224.0.0.251(5353) <-mDNS
- Socket#3:SOCK_OPEN 21 D:0.0.0.0(0) <-ftp
- Socket#4:SOCK_OPEN 50009 D:0.0.0.0(0) <-ftp
- Socket#5:CLOSE_WAIT 502 D:192.168.24.40(33538) <- modbus
- Socket#6:CLOSE_WAIT 502 D:192.168.24.40(39572) <- modbus
- Socket#7:CLOSE_WAIT 502 D:192.168.24.46(49412) <- modbus
If anyone else is troubleshooting tcp/ethernet stuff, here is some useful code.
Not an expert, but I think you are limited due to the Ethernet library, which is probably limited by the RAM of the M0 chip. Maybe there's an Arduino library out there that can do more sockets, but I have not come across one.
I was really hoping someone would tell me my google-fu failed and there is something like an ENC board or some other devices that we could use instead.
It looks like both your ModbusTCP Clients each have two half-open TCP connections? Why does the SCADA open a new TCP for each communication packet? What is your SCADA package and why does it operate that way? It should just continue to use the existing connection.
192.168.24.46(53384) Client1, Connection2
192.168.24.40(33538) Client2, Connection1
192.168.24.40(39572) Client2, Connection2
192.168.24.46(49412) Client1, Connection1
I'm unfamiliar with using the W5100 library. If you look at the AutomationDirect examples, lines 82-89 here are used to clean up closed connections. Is there a similar method in W5100?
https://github.com/AutomationDirect/P1AM-Examples/blob/master/P1AM-100_ModbusTCP_Server_HMI/P1AM-100_ModbusTCP_Server_HMI.ino
A wireshark capture may also be helpful.
For SCADA, we are using Node-Red with a little modbus module I wrote a bit ago. After checking it, I was closing the connection after each run. I'll fix that tomorrow, thanks for pointing it out!
The Ethernet.h library is what we use to communicate with the W5300 inside of the P1AM-eth module. The W5100 is the lighter/original version of the W5300. You can use the utility/w5100.h (which comes paired with Ethernet.h) to get some of the extended options like what is in my above code chunk.
The fat version of my .ino actually started out as the one you linked 😅