Skip to content
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

🥵 Request a different error each time without using load balancing(Check out the details) #2246

Closed
NingLiu1998 opened this issue Sep 8, 2023 · 3 comments
Labels
Type: Bug Something isn't working

Comments

@NingLiu1998
Copy link

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

The request is for the same address, and the following problems will appear randomly on each refresh

  • 💀 Status Code: 502; Bad Gateway
[2023-09-08 10:07:42 INF] (23) Proxying to https://localhost:8661/swagger/Default/swagger.json HTTP/2 RequestVersionOrLower no-streaming

[2023-09-08 10:07:42 INF] (27) Request: An error was encountered before receiving a response.
 System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
 ---> System.IO.IOException: Cannot determine the frame size or a corrupted frame was received.
   at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter)
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.GetHttp2ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at Yarp.ReverseProxy.Forwarder.HttpForwarder.SendAsync(HttpContext context, String destinationPrefix, HttpMessageInvoker httpClient, ForwarderRequestConfig requestConfig, HttpTransformer transformer)
  • 💀 Value cannot be null. (Parameter 'destinationPrefix')
[2023-09-08 10:09:09 ERR] (24) 耗时:1065ms,系统异常:/api/emr-swagger
 System.ArgumentNullException: Value cannot be null. (Parameter 'destinationPrefix')
   at Yarp.ReverseProxy.Forwarder.HttpForwarder.SendAsync(HttpContext context, String destinationPrefix, HttpMessageInvoker httpClient, ForwarderRequestConfig requestConfig, HttpTransformer transformer)
   at Yarp.ReverseProxy.Forwarder.ForwarderMiddleware.Invoke(HttpContext context)
   at Yarp.ReverseProxy.Health.PassiveHealthCheckMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at TWZHIS.Cloud.Middlewares.ApiLogMildd.InvokeAsync(HttpContext context) in D:\ln2023\WorkProject\TWZHIS.Cloud\TWZHIS.Cloud.Extensions\Middlewares\ApiLogMildd.cs:line 87

Here's my configuration

"ReverseProxy": {
    "Logging": {
      "LogLevel": {
        "Default": "Information",
        // Uncomment to hide diagnostic messages from runtime and proxy
        // "Microsoft": "Warning",
        // "Yarp" : "Warning",
        "Microsoft.Hosting.Lifetime": "Information"
      }
    },
    "Routes": {
      "routeEmr": {
        "ClusterId": "clusterEmr",
        "Order": 90,
        "Match": {
          "Path": "/api/emr/{**everything}"
        },
        "Transforms": [ // 转换列表。有关更多详细信息,请参阅Transforms文章 这个的看到后面的文档再说了
          //{ "PathRemovePrefix": "/emr" }
          { "PathPattern": "/api/{**everything}" }
        ]
      },
      //----
      "emrswagger": {
        "ClusterId": "clusterEmr",
        "Order": 100,
        "Match": {
          "Path": "/api/emr-swagger"
        },
        "Transforms": [ // 转换列表。有关更多详细信息,请参阅Transforms文章 这个的看到后面的文档再说了
          //{ "PathRemovePrefix": "/emr" }
          { "PathPattern": "/swagger/Default/swagger.json" }
        ],
        // 可由自定义扩展使用的键值对列表 
        "MetaData": {
          "IsSwaggerJson": true
        }
      },
      "route2": {
        "ClusterId": "cluster2",
        "Match": {
          "Path": "/testyarn/{**everything}"
        }
      }
    },
    "Clusters": {
      "clusterEmr": {
        "Destinations": {
          "destination1": {
            "Address": "https://localhost:8661"
          },
          "HealthCheck": {
            "Active": {
              "Enabled": "true",
              "Interval": "00:00:10",
              "Timeout": "00:00:10",
              "Policy": "ConsecutiveFailures",
              "Path": "/api/system/health"
            }
          }
        }
      },
      "cluster2": {
        "Destinations": {
          "destination1": {
            "Address": "http://www.baidu.com"
          },
          "destination2": {
            "Address": "http://www.google.com"
          }
        }
      }
    }

  }

I only do the configuration, in addition to no additional control in the code

↓ code vew

image

image

Further technical details

  • Use Windows 😗
  • TargetFramework:net5.0 😍
  • PackageReference:Yarp.ReverseProxy 1.1.2 😍

😥 In addition, my English level and professional technology level is low, I want to claim the company encountered when using yarp has problem, if you can, can help analyze the problem of what might be the reason

@NingLiu1998 NingLiu1998 added the Type: Bug Something isn't working label Sep 8, 2023
@NingLiu1998
Copy link
Author

NingLiu1998 commented Sep 8, 2023

I refer to the document: → https://microsoft.github.io/reverse-proxy/index.html

The translator I use is:youdao

@NingLiu1998
Copy link
Author

NingLiu1998 commented Sep 8, 2023

There is a problem to find the cause, I filled in the configuration is https://localhost:8661 in fact, my api is http://localhost:8661, so it will cause SSL errors

After this problem is solved, it will still exist

The request is for the same address, and the following problems will appear randomly on each refresh

This problem

Sometimes error:
image

Sometimes success:
image

@NingLiu1998
Copy link
Author

。。i find #2175 maybe is HealthCheck no address √

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant