twitchax / AspNetCore.Proxy

ASP.NET Core Proxies made easy.
MIT License
505 stars 80 forks source link

Reuse connection issue with SSL #91

Closed aik0n closed 2 years ago

aik0n commented 2 years ago

Hi, I have an odd problem. Described at Reuse connection error

After some resolving phase SSRS in this case was published with SSL and an error was changed. A current one is:

Request could not be proxied.

The SSL connection could not be established, see inner exception.

So, how to resolve this? How I can log inner exception in this case? I mean release published application. Is AspNetCore.Proxy lib has any options to use logger? Should I add custom middleware logger?

aik0n commented 2 years ago

Application http - SSRS http - works Application https - SSRS http - reuse connection issue Application https - SSRS https (IP address) - certificate issue Application https - SSRS https (DNS name) - reuse connection issue Application https - SSRS https (ignore SSL errors) - reuse connection issue

So, how to resolve "reuse connection issue"?

twitchax commented 2 years ago

Hello!

Sorry, I was away on vacation, and I jsut now saw this.

The connection reuse issue probably has to do with Keep-Alive headers. Can you try editing your HttpClient? Try adding...

myHttpClient.DefaultRequestHeaders.ConnectionClose = false;
aik0n commented 2 years ago

Hello. Thanks for help. I added recomended settings and this not resolve the problem. Also, I added a test proxy map route and have no problem with it. So, the problem not in proxy lib, maybe network specific thing.

PS I use iframe with post action to application API This request will be proxied with the can't reuse connection error

PPS HTTP Client configuration:

image

twitchax commented 2 years ago

Ok, that was worth a try. Kind of difficult to serving without a repro on my end. Do you have a similar minimal case that you can share, but using a public endpoint?

aik0n commented 2 years ago

It is difficult to coordinate with all interested parties. Just for tests I added ".WithBeforeSend()" and keep-alive header in it. It is not resolve the issue but error was changed. Researching in progress...

image image

twitchax commented 2 years ago

Interesting: maybe something to do with this?

aik0n commented 2 years ago

Okay, finally I have works solution. No issues in proxy lib. Details matter. Thank you for this support and advices and great proxy package.

In details: In my case was helpful add .WithBeforeSend() Later I will provide full config. The error message "The function requested is not supported" also happens with wrong credentials (or blocked user) I didn't install any kerberos or NTLM fixes, service packs. In my case SSRS execution user was blocked after deploy to test environment. Also test env has different domain name. Miscommunications with other team members and human aspect :)

How SSRS was integrated

  1. Application (ASP.NET Core MVC) -> Request to build HTML form with report parameters to SSRS. Parameters depends on user input and selections.
  2. Web URL access to SSRS with HTTP POST (SSRS feature). So SSRS build report by it own and return result with built in controls, etc.
  3. Application has access from external network SSL, VPN. SSRS has access only from internal network
  4. This project proxy lib used to catch special formed URL from HTML form and redirected to internal SSRS
  5. Rendered report displayed in iframe
  6. Config hell ...
  7. Profit :)

HttpClient initialization:

image

Proxy map initialization:

image

twitchax commented 2 years ago

Interesting: glad you got it figured out!