Gents --

Gents --

I know this is a totally open ended question with little information, but here goes......

Can anyone think of a reason that a socket server application would hum along just fine accepting connections, and then suddenly stop, giving the dreaded 10061 error (Connection actively refused)?

That's happening to me and I don't have many more details than that.

Comments

  1. I would just like to point out we have a few very fine ladies around here who may rightfully feel that "gents" does not represent them :-)

    ReplyDelete
  2. Are you leaking socket handles and run out?

    ReplyDelete
  3. If threads are involved, the creating thread owns the responsibility from cradle to grave, and trying to release the handle in the wrong thread causes a leak, if I remember correctly.

    ReplyDelete
  4. Andrea --  You are correct --- my apologies.

    ReplyDelete
  5. Lars -- how do you leak a socket handle?

    I should add that this is hand-code, raw WinSock code.

    ReplyDelete
  6. Nick Hodges Whose hand-code? Yours? Or legacy stuff?

    ReplyDelete
  7. Let me count the ways from the top of my head...
    Mismatched
    - WSAStartup/WSACleanup
    - Connect/Disconnect
    - AcceptEx/CloseSocket
    and various other combos.

    ReplyDelete
  8. If you are leaking handles - that should be easy to verify with SysInternals TCPView or SysInternals Process Explorer, or Process Hacker.

    ReplyDelete
  9. If you have MadExcept 4+, it also has the ability to show you any resource leaks.

    ReplyDelete
  10. I once had similar problems. Sporatic 10061s. After chasing this for a couple of weeks, we found a loose cable in the local hub. Fixed it and no more 10061s!

    ReplyDelete
  11. Lars --  Found a WSAStartup call, but no WSACleanup.  Matching with a WSACLeanup didn't seem to help.

    How does TCPView report leaking handles?

    ReplyDelete
  12. If you have a growing number of idle (Established / Listening - but no traffic) ports, they are probably connections which have not been closed correctly.  I don't know if you control both ends of the session, or if there is a protocol layer - but if you have - you might want to check that the protocol hangs up correctly as well.

    If you can't find indications of a handle leak - another options could be some sort of memory corruption?

    ReplyDelete
  13. fiddler mikey To the contrary, rule it out early, be sure, as it's easier to remedy than chasing all over the place in code, trying to discover what may not be there.

    ReplyDelete
  14. I think fiddler mikey meant that you should check your HW, Bill Meyer.

    Nick Hodges - Same symptom on different hardware?

    ReplyDelete
  15. I didn't write the code.... it's legacy. I own both ends of the connection. I'm confident hardware isn't the issue.

    ReplyDelete
  16. Yes Lars Fosdal  trying to convey a rational message on a mobile device doesn't always work out so well.

    ReplyDelete
  17. If you find the cause, Nick Hodges - it would be fun to know what it was :)

    ReplyDelete
  18. Sounds like ressource exhaustion or a network timing issue to me. How many connections does the server accept until it happens, and what is the component you're using? Do you have a network trace of working and failing connections?

    ReplyDelete
  19. Jasper Thayer resource exhaustion gives another error code. Nick Hodges error 10061 is sent by the OS whenthere is no application listening on the port. This could also comes from buggy "security" product which poorly intercept winsock calls. It can also happen with malware intercepting winsock call. When you use netstat, does it still shows a listening port on the expected port/protocol? A bug in the software could inadvertely close the listening socket handle.

    ReplyDelete

Post a Comment