Network client sketch 'hangs' without client.stop() before client.connect(..)


I've been having problems with my sketch crashing (or hanging in a loop somewhere with no sign of any activity) and have now (I think) resolved the problem.

My sketch runs various sensors and periodically (once a minute in fact) uploads data to Weather Underground.

I have read through my code over and over looking for somewhere that the code could hang but found nothing; then I found an example of ethernet client code that called client.stop() before opening a new connection with client.connect(...)

Having implemented this my code is now running with no crashes.

I can only assume that somehow my (frequent) outgoing connections were occasionally hanging and when I requested a new connection the ethernet shield had no free outgoing sockets and was blocking while waiting for a free socket?

I don't know if the ethernet library code should be looked at to avoid this, but in my case preceding the client.connect call with a client.stop appears to have fixed the problem.

Hopefully this will be of help to someone. George

My client code doesn't hang. It has all the latest bug fixes I could find, including a timeout feature in the event the server stalls or the connection breaks. Maybe you should post your code if you expect to help anybody with it.