CLOSE_WHAT & crashing

CLOSE_WHAT & crashing SearchSearch
Author Message
Ramon Sazon
New member
Username: Ramonsazon

Post Number: 21
Registered: 08-2006
Posted on Friday, March 30, 2007 - 02:11 pm:   

Hi Bryce/Malcolm,

I found a strange occurrence as I was stress testing our configuration. It's a Windows2003 server with nowsms 5.51 running on it.

I am able to send SMS using a GET method to IP:PORT of NOWSMS using winhttp in my app. It works fine in the beginning but after a while (half a day to reproduce in my test env), it runs out of ports to bind to and can't send anymore and it also crashes our other application. The error my sending app gets is "address in use". I did a netstat -a and found out that I had hundreds if not a couple of thousands of CLOSE_WAIT in my system.

After some research, I found out this:
"A socket application has been terminated, but Netstat reports the socket in a CLOSE_WAIT state. This could indicate that the client properly closed the connection (FIN has been sent), but the server still has its socket open. This could be the result of one instance (among all threads or processes) of the socket not being closed."

The server in this case is IP:PORT of NowSMS. Is this a bug with NOWSMS 5.51? Why isn't NOWSMS closing the connection? As I understand, my app sends a close flag and the nowsms server needs to send one back but it's not receiving one putting the socket into close_wait state.

Attached is the netstat output before and after reboot (which is the only way to release all the ports and make my app work again).

Please let me know how I can close the connection and release the ports properly. As always, I appreciate your help and guidance as we explore NowSMS. Please let me know if you need additional info.
Thank you.
RS


text/plainNetstat Before
netstat-before.txt (268.2 k)
text/plainNetstat After
netstat-after.txt (3.1 k)
Ramon Sazon
New member
Username: Ramonsazon

Post Number: 22
Registered: 08-2006
Posted on Friday, March 30, 2007 - 02:12 pm:   

Opps. Sorry, I meant CLOSE_WAIT, not CLOSE_WHAT.
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 7038
Registered: 10-2002
Posted on Wednesday, April 04, 2007 - 10:36 pm:   

Hi Ramon,

NowSMS goes out of its way to try to gracefully close socket connections when it can. (It waits up to 60 seconds for confirmation of the close request before it closes the socket.)

But even so, this is puzzling, because a socket should not stay in a CLOSE_WAIT state for more than 120 seconds ... although I believe there are registry parameters to modify this.

Are you connecting on the loopback address ... 127.0.0.1?

It seems like I recall a Windows problem with CLOSE_WAIT states and 127.0.0.1.

Can you try changing to a real IP address from your application and see if that makes a difference?

-bn
Ramon Sazon
New member
Username: Ramonsazon

Post Number: 23
Registered: 08-2006
Posted on Saturday, April 07, 2007 - 07:24 am:   

Hi Bryce,

Works fine now. I forgot to close the connection when I did the GET request.

Thank you.
RS