1

Every 30 to 60ish minutes, our app's email notifications (via System.Net.Mail.SmtpClient) stop sending. As soon as we recycle the app pool, the emails start flowing again. I have checked and double-checked the code and added additional USING statements to make certain all SmtpClient-related objects are being properly disposed after use. If it were an SMTP issue I don't think recycling the app pool would fix it. Has anyone else encountered this issue and figured out the root cause and fix?

Ryan
  • 253
  • 3
  • 17
  • Do you have idle time-out set up in your app pool (default is 20 minutes)? Any messages about your app pool in system logs? – Sergey Fadeev Apr 18 '16 at 19:44
  • Are the notifications in response to some activity or is it something that's scheduled to run periodically? ASP.NET is a request/response platform, so if there are no actual requests the app may be shut down by IIS. – D Stanley Apr 18 '16 at 20:26
  • The notifications are in response to certain activities. – Ryan Apr 19 '16 at 01:44

2 Answers2

1

As far as I see from the previous experience with Quartz.NET, the problem is most probably related to IIS rather than the schedulers i.e. Quartz.NET, Hangfire, etc. You might try to install Keep Alive Service For IIS 6.0/7.5 on the server to which you publish your application. After that, your published application will be alive after application pool recycling, IIS/Application restarting, etc.

Note: If you use IIS 7.5 and above you can use the last version of Keep Alive as well.

Murat Yıldız
  • 11,299
  • 6
  • 63
  • 63
0

Possible solution in this SO answer: Email sending service in c# doesn't recover after server timeout

Bump maxconnections in your web.config

Alex from Jitbit
  • 53,710
  • 19
  • 160
  • 149