I have one controller which polls two irrigation controllers using http to obtain JSON (Java Script Object Notation) data which allows me to know which water valves are on. The program fine for 1-2 hours then finally the ethernet controller indicates that it cannot access the two irrigation controllers. After some diagnostic work, it seems the ethernet shield does not close connections properly and after a period of time it runs out of sockets to communicate with. The code attached the portion which handles the communication with the two irrigation controllers. Any assistance would be appreciated.
Here's a typical serial output at 4 minutes after startup:
Uptime: 4 Mins.
Connecting To House Controller.
Connection Status: 1
Socket#0:0x17 80 D:192.168.0.162(64260)
Socket#1:0x22 8888 D:132.163.4.101(123)
Socket#2:0x17 1121 D:192.168.0.102(80)
Socket#3:0x0 0 D:0.0.0.0(0)
Flushing & Stopping House Controller.
Connecting To Coral Controller.
Connection Status: 1
Socket#0:0x17 80 D:192.168.0.162(64260)
Socket#1:0x22 8888 D:132.163.4.101(123)
Socket#2:0x17 1122 D:192.168.0.104(80)
Socket#3:0x0 0 D:0.0.0.0(0)
Flushing & Stopping Coral Controller.
Here's some typical data once the failure has occurred:
Uptime: 73 Mins.
Connecting To House Controller.
Connection Status: 1
Socket#0:0x17 1532 D:192.168.0.104(80)
Socket#1:0x22 8888 D:132.163.4.101(123)
Socket#2:0x17 2371 D:192.168.0.102(80)
Socket#3:0x17 2468 D:192.168.0.102(80)
Flushing & Stopping House Controller.
Connecting To Coral Controller.
Connection Status: 1
Socket#0:0x17 1532 D:192.168.0.104(80)
Socket#1:0x22 8888 D:132.163.4.101(123)
Socket#2:0x17 2371 D:192.168.0.102(80)
Socket#3:0x17 2469 D:192.168.0.104(80)
Flushing & Stopping Coral Controller.
Uptime: 73 Mins.
Connecting To House Controller.
Connection Status: 0
Socket#0:0x17 1532 D:192.168.0.104(80)
Socket#1:0x22 8888 D:132.163.4.101(123)
Socket#2:0x17 2371 D:192.168.0.102(80)
Socket#3:0x17 80 D:192.168.0.127(53599)
Initial Connection Request To Irrigation Controller Failed On House Controller.
Flushing & Stopping House Controller.
Connecting To Coral Controller.
Connection Status: 0
Socket#0:0x17 1532 D:192.168.0.104(80)
Socket#1:0x22 8888 D:132.163.4.101(123)
Socket#2:0x17 2371 D:192.168.0.102(80)
Socket#3:0x17 80 D:192.168.0.127(53599)
Initial Connection Request To Irrigation Controller Failed On Coral Controller.
Flushing & Stopping Coral Controller.
code.ino (3.26 KB)