c# - .Net SMTPClient leaves connection in WAIT_CLOSE -


i have issue plaguing me. every 2 3 days, end getting connections our smtp provider don't finish closing. running netstat on server shows connection status of close_wait. researching thought had narrowed down object not being disposed of properly.

specifically .net smtpclient class in previous version of framework did not implement idisposable. when moved 4.0 framework never needed go , update this, meaning we've been along time without these errors. few weeks ago started having problem. started when our provider had outage on servers. in theory still having intermittent issues not broadcasting. in either case code needs able recover , keep going.

i've been through every piece of code sends emails, , they've been fixed. every mailmessage object , every smtpclient object in using statement. still issue randomly. when happen seems happen multiple times close together, doesn't happen days.

the worst of problem once end 2 connections same server state, subsequent messages pool waiting additional resource, time out. resetting service fixes issue.

i know there posts out there stating configuration can adjusted allow more simultaneous connections. doesn't fix problem, masks bit.

my statement above incorrect.

"i know there posts out there stating configuration can adjusted allow more simultaneous connections. doesn't fix problem, masks bit."

i adjusted allowed connections in config file expecting give me more time actively monitor problem , proactively address while continuing solution.

as added configuration value problem has stopped completely.

<system.net>   <connectionmanagement>     <add address="{addressgoeshere}" maxconnection="10" />   </connectionmanagement> </system.net> 

in fact, 1 of our lesser used services didn't apply configuration update processed fewer emails , wasn't susceptible. 1 broke while more heavily used ones still working charms.

i'd love know more of why. best understanding trying open more connections server allowed , causing hung up. default of 2 connections piling them behind , in cases .net seemed timeout while connection open not disconnecting @ os level. (eg. 28 seconds waiting connection, needed 3 seconds process killed @ 30 second time.)

now i've allowed 10 connections processing more threads simultaneously , not backing waiting slot open up. haven't had single problem new configuration in past week.

i hope can sleep better did few nights :)


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -