ASP.NET Core с React - 431 Слишком длинный запрос заголовков - PullRequest
0 голосов
/ 03 мая 2019

У меня есть приложение dotnet, которое я запускаю командой dotnet run.У меня также есть приложение React, которое я запускаю с yarn start.

Когда я открываю браузер на localhost:3000 (где находится приложение реагирования), журнал сервера выглядит так:

....this goes on for long
 Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/build/bundle.js  
info: Microsoft.AspNetCore.Server.Kestrel[17]
      Connection id "0HLMFVTO65C53" bad request data: "Request headers too long."
Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request headers too long.
   at Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason reason)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TakeMessageHeaders(ReadOnlySequence`1 buffer, SequencePosition& consumed, SequencePosition& examined)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.ParseRequest(ReadOnlySequence`1 buffer, SequencePosition& consumed, SequencePosition& examined)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TryParseRequest(ReadResult result, Boolean& endConnection)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication`1 application)

Примерно через 15 секунд после этого страница загружается, но в консоли браузера появляется ошибка об ошибке bundle.js 431.

Если я увеличу максимальный общий размер RequestHeaders для сервера Kestrel,происходит то же самое, но это продолжается еще дольше, и конечным результатом является ошибка сервера 500 вместо 431.

Более того, если я попытаюсь сделать простой запрос DELETE к серверу, используя почтальон, результат будет в значительной степенитот же самый.Как будто запрос застрял в бесконечном цикле, а затем возвращает 431.

Строки из Startup.cs, которые могут иметь отношение:

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
     {
          configuration.RootPath = "client/build";
     }
);


app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            }
);
app.UseSpaStaticFiles();
app.UseSpa(spa =>
            {
                if (env.IsDevelopment())
                    spa.UseProxyToSpaDevelopmentServer("http://localhost:3000");
            }
);

Что происходит?

...