Urllib.retrieve not closing tcp ip ports

We are working in ignition 7.9.10. I have created a script using urllib.urlretrieve to pull still images from Axis network cameras on a tag change event. Then save them to a mapped drive on the server.

The issue I’m having is that I am getting a ton of BOUND, ESTABLISHED, and CLOSE_WAIT ports. This is essentially running my server out of dynamic tcp ip ports. After some reading it doesn’t seem that urllib supports persistent connections. Also, urlretrieve function has a built in close. Resetting the NIC on the server drops the close_wait ports, but it is something I’ve had to do manually and I’m not sure if it has contributed to the bound and established connections that are not dropping off.

I have been running this same setup on another server running Ignition 8, and after running the same powershell script to observe the port status it has 0 close_wait connections.

Does anyone know of an alternative to urllib that works in Ignition 7.9? Or any other suggestions to help with the port issues? It seems once it is clogged the only true fix is to restart the server. However, this is a production server.

Any help is appreciated! Thanks.

**** SOLVED ****

We were incorporating a PLC tag value for the filename. It seems that the value being provided was not valid sometimes causing the urlretrieve to never complete and leaving the ports in close_wait status.

If it works in 8, I’d do a minor version upgrade to 7.9.17… that’s 2 years worth of bug fixes, decent chance it would solve the problem

Check the change logs - If it isn’t fixed in an update, I’ve been using the very nearly undocumented .close() statement since 7.9.7.

	apiRequest 	= urllib2.Request(endPoint, data, header)
	apiResponse	= urllib2.urlopen(apiRequest)
	qctResponse	= apiResponse.read()
	apiResponse.close()	# actively close the connection JIRA Issue: QCT-1678

1 Like