10

I have two sites running on my development machine for the last 8 months or so. Both sites use ASP.NET Core, and both are running on Kestrel behind IIS.

During the last couple of weeks, the sites have become a headache. After building or restarting IIS, the sites work fine, but a few minutes later, they get unresponsive. Nothing, and I mean absolute nothing happens when I access them in a browser, or from any another application. No output is shown in VS (if the debugger is attached it fails anyway). If I enable stdout in web.config, I can see that it takes serveral seconds, just to log the query of a statement from Entity Framework. The problem persists if I disable stdout.

My machine is an i7-6700K with 16 gb ram. When this is happening my CPU usage is around around 0-3%, and the last time I checked I had 50% free of memory.

Both sites are using MySQL server 5.7 which is also used by other applications at the same time. Regular ASP.NET websites work fine when this is happening.

NuGet packages used in both projects:

  • IdentityServer4 2.0.4
  • IdentityServer4.EntityFramework 2.1.0
  • MailKit 2.03
  • Microsoft.AspNetCore.All 2.0.7
  • Microsoft.VisualStudio.Web.CodeGeneration.Design 2.0.0
  • MySql.Data 8.0.11
  • NLog 4.5.3
  • NLog.Web.AspNetCore 4.5.2
  • Pomelo.EntityFrameworkCore.MySql 2.0.1

Furthermore, Project A is referencing:

  • IdentityServer4.AspNetIdentity 2.1.0
  • Microsoft.EntityFrameworkCore.Tools 2.0.2
  • NETStandard.Library 2.0.2
  • Ngonzalez.ImageProcessorCore 0.0.1

Project B is referencing:

  • Hangfire 1.6.17
  • Hangfire.MySql.NetCore 1.0.7
  • IdentityServer4.AccessTokenValidation 2.1.0
  • Microsoft.AspNetCore.Mvc.Versioning 2.0.0

Software versions:

  • Visual Studio Enterprise 2017 version 15.6.7
  • dotnet --version: 2.1.105
  • Windows 10 Pro 1709 16299.371

Both sites are working fine in our production Web server, the issue is only happening in my development machine, and with the exact same builds!

Update 2018-05-08

I have tried setting nLog dbProvider and removed MySql.Data NuGet package as suggested by Mark G. but the problem is still there.

Have formatted and installed the whole PC. No change.

Update 2018-05-09

Debugging seems keeping the sites alive.. but thats not a viable solution.

Update 2018-05-09

Now it also happens in production.

Update 2018-05-09

I have tried an earlier version of the sites, where NLog wasn't implemented yet, and therefore no MySql.Data, and Microsoft.AspNetCore.All isn't forced to 2.0.7, just 2.0.0, and I have the same results.

I have also tried updating all NuGet packages to the newest versions without luck.

Update 2018-05-11

I might be getting close to find a solution. I have removed the following two lines of code from my Startup.Configure() which always have been there. It looks promising, but I havent had too much time to test, but as far as I can tell it have solved the problem for now! :)

loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
Nicky
  • 428
  • 3
  • 13
  • Might be worth profiling the database connections and the activity. How many active connections are allowed on your dev server? Hangfire will probably be polling relatively frequently. – SpruceMoose May 04 '18 at 11:52
  • 151 allowed (MySQL standard setting). I have 18 open connections when it's bugging and all is sleeping. But yeah, Hangfire is a hog, but not enough to do do this. – Nicky May 04 '18 at 11:53
  • In that case, what has changed in the last two weeks? – SpruceMoose May 04 '18 at 12:00
  • Added NLog (still bugs when disabled), and force updated minimum runtime from 2.0.0 to 2.0.7 due to bugs. The sites still works like a charm on our production servers.. – Nicky May 04 '18 at 12:43
  • You reference MySql.Data and Pomelo.EntityFrameworkCore.MySql, are you using both? – Mark G May 04 '18 at 15:25
  • Yeah Mark. The projects was started way before MySql.Data supported Entity Framework Core, and is not compatible with our current migrations. MySql.Data is only used for NLog. – Nicky May 04 '18 at 17:57
  • Maybe try setting dbProvider to "MySql.Data.MySqlClient.MySqlConnection,MySqlConnector" in nlog.config file and remove MySql.Data library. Also see if [.NET core: Hangfire setup with NLog](https://stackoverflow.com/questions/49933967/net-core-hangfire-setup-with-nlog) is related. – Mark G May 04 '18 at 20:25
  • Wouldn't hat setting require that the assemblies is referenced? Also, I'm already using the solution from that thread, and Hangfire logging works fine. :( – Nicky May 04 '18 at 21:16
  • Pomelo uses [MySqlConnector](https://github.com/mysql-net/MySqlConnector) under the hood so you can configure NLog to also use that instead of the MySql.Data library. – Mark G May 04 '18 at 22:42
  • Ok thanks. That will make the references a little prettier :) – Nicky May 04 '18 at 23:53
  • That didn't help :/ – Nicky May 08 '18 at 13:04
  • @Nicky, you say the site becomes unresponsive. What is the response exactly when you make a request? 404? 5**? – Judy007 May 09 '18 at 02:22
  • Nothing. They just hang... the browser keeps loading, and cross-site communication times out. After a few request, they just stop responding. – Nicky May 09 '18 at 06:20
  • 1
    Have you tried using a profiler? Something like [CodeTrack](http://www.getcodetrack.com/)? – Mark G May 10 '18 at 16:20
  • @Nicky, Every request leads to some type of response. "Nothing" is not a response. Im asking about the exact response CODE. https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html – Judy007 May 10 '18 at 16:53
  • @Joey There is no response. Ergo, nothing. The server never responds to the request. I know how the HTTP protocol works, and there is no response CODE, when the server never returns a response. The request is hanging for infinity. When site is called back end from another site, I get a timeout exception. Browser just keeps waiting. Restarting the process results in a http 502.2 Bad gateway. – Nicky May 11 '18 at 18:14
  • If I was you, I would avoid trial and error and just completely reinstall IIS. https://blogs.msdn.microsoft.com/friis/2017/01/16/how-to-perform-a-clean-reinstallation-of-iis/. That will rule out any issues with configuration of IIS, which could be the culrpit – Judy007 May 11 '18 at 18:50
  • @joey: Thanks, but I have already formatted the PC, and the problem continued. – Nicky May 11 '18 at 19:14
  • @MarkG: No, but I will check CodeTrack out, if the problem isn't solved. Thanks. – Nicky May 11 '18 at 19:14
  • To all: The problem might be solved. Update will follow. Thanks. – Nicky May 11 '18 at 19:14
  • Make sure both sites are running in different application pools so if one crashes, it will not affect the other, also check the server event viewer, sometimes you have interesting error messages there that lead to the root of the error. – Isma May 11 '18 at 21:24
  • Did you manage to locate the error? I am seeing similar problems on a similar setup. Asp.Net Core 2.1. Sometimes the page take upwards 50 seconds to load a simple .png file. It does not happen all the time. – Sha Jun 15 '18 at 01:57
  • Sha, I have any trouble since I removed the two lines of code from my 2018-05-11 update. I have 7 projects running concurrent locally without any issues, and it also solved problem with ultralong responses in production. – Nicky Jun 17 '18 at 08:13

0 Answers0