Skip to content

Sporadic 502 responses to GET requests #13851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gaborbuzasi opened this issue Sep 10, 2019 · 7 comments
Closed

Sporadic 502 responses to GET requests #13851

gaborbuzasi opened this issue Sep 10, 2019 · 7 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-iis Includes: IIS, ANCM

Comments

@gaborbuzasi
Copy link

Our app is a .NET Core 2.2 Web API, which is running on an Azure App Service (windows) with InProcess hosting mode.

We receive sporadic 502 responses to CORS GET requests when using the API with an SPA running VueJS. This seems to be happening only when making requests from an SPA, not in case of a native/desktop client. This is occurring across all of our environments and causes disturbance in production.

The requests contain the Origin which is allowed in the API in all cases.

See the error (as in the browser)
sp-error-1

See the error below (captured by Fiddler):

HTTP/1.1 502 Bad Gateway
Content-Type: text/html
Server: Microsoft-IIS/10.0
Date: Tue, 10 Sep 2019 10:18:59 GMT
Content-Length: 1477

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>502 - Web server received an invalid response while acting as a gateway or proxy server.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>502 - Web server received an invalid response while acting as a gateway or proxy server.</h2>
  <h3>There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.</h3>
 </fieldset></div>
</div>
</body>
</html>

Allowing CORS requests are configured the following way (with the array containing a list of strings as URLs):

            app.UseCors(builder => builder.WithOrigins(Settings.Authentication.AllowedCorsOrigin.ToArray())
                                          .AllowAnyHeader()
                                          .AllowAnyMethod());

However, given that the very same requests sometime succeed, I believe it is unlikely that there is an issue with CORS here.

Our azure app service has the following installed:

dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.108
 Commit:    33ed5b90ce

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x86
 Base Path:   D:\Program Files (x86)\dotnet\sdk\2.2.108\

Host (useful for support):
  Version: 3.0.0-preview6-27804-01
  Commit:  fdf81c6faf

.NET Core SDKs installed:
  1.1.14 [D:\Program Files (x86)\dotnet\sdk]
  2.1.506 [D:\Program Files (x86)\dotnet\sdk]
  2.1.701 [D:\Program Files (x86)\dotnet\sdk]
  2.2.107 [D:\Program Files (x86)\dotnet\sdk]
  2.2.108 [D:\Program Files (x86)\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.10 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.12 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.5 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.6 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.10 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.12 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.5 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.6 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.16 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.13 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.11 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.12 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.5 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
@gaborbuzasi
Copy link
Author

Seem to be receiving this at the same time when the errors happen:

[Error] Connection ID ""13618885274778993237"", Request ID "null": An unhandled exception was thrown by the application.
System.ObjectDisposedException: The CancellationTokenSource has been disposed.
   at System.Threading.CancellationTokenSource.ThrowObjectDisposedException()
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.<>c__DisplayClass313_0.<AbortIO>b__0(Object t)

@gaborbuzasi
Copy link
Author

#4422 may be related

@mkArtakMSFT mkArtakMSFT added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 10, 2019
@mkArtakMSFT
Copy link
Contributor

Thanks for contacting us, @gaborbuzasi.
@shirhatti, @Tratcher is this a known issue in 2.2? Is this really a dupe of the referenced issue?

@Tratcher Tratcher added area-servers feature-iis Includes: IIS, ANCM and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Sep 11, 2019
@Tratcher
Copy link
Member

Yes, the ObjectDisposedException looks like an issue we've addressed in 3.0 via #9389. @gaborbuzasi trying 3.0 would be a good way to verify.

@shirhatti
Copy link
Contributor

@gaborbuzasi How are you hosting your application? Are you running kestrel directly or hosting behind IIS or Azure App Service?

@gaborbuzasi
Copy link
Author

gaborbuzasi commented Sep 13, 2019

@gaborbuzasi How are you hosting your application? Are you running kestrel directly or hosting behind IIS or Azure App Service?

@shirhatti
I'm hosting it in Azure App Service

@analogrelay
Copy link
Contributor

We believe this to be fixed in 3.0 which is releasing this month. Please try updating when it's released and if your issue still reproduces, let us know and we can investigate further!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-iis Includes: IIS, ANCM
Projects
None yet
Development

No branches or pull requests

6 participants