0

I have a WebApp (Ionic App) and DotNet Core WebAPI service. I hosted it on 2 different IIS Server i.e. Server1 and Server2. Sometimes, my application doesn't behave correctly on Server2. When I debug the code and looked at logs, I found strange behavior in the WebAPI logs.

Server1: The app is working fine. If I look at the logs, I can see the HTTP/2.0 protocol for all the API requests. There is not a single request for HTTP/1.1.

Request starting HTTP/2.0

Server2: The app is not behaving properly. I can see two protocols for the API requests. Sometimes I can see HTTP/1.1 protocol and sometimes HTTP/2.0 protocol.

Request starting HTTP/1.1
Request starting HTTP/2.0

The main issue on Server2: These two protocols used for a single request. Let's say When I hit an API(GetData) from my app, I can see two requests of GetData in the logs. The only difference is both requests have different HTTP protocols i.e. HTTP/1.1 and HTTP/2.0.

When I check Chrome developer's tool for network calls, I can see only a single call made by the app. In the network tab, the protocol is HTTP/1.1. For the same request, I can see two different requests in the API logs with different HTTP protocols. Also, I can see that everything works fine on the HTTP/2.0 request in the API logs (the logic of the API) but my app has been waiting on the HTTP/1.1 request. So, my app doesn't get a response back from the API on HTTP/1.1 and shows an error on the app.

GetData API implementation: I am fetching some data from the 3rd party service. 3rd party service can return data only once for a single session id. As I am getting two requests (means, GetData code executing twice), I received the data from 3rd party service on HTTP/2.0 protocol request but not on HTTP/1.1. So, the request which uses HTTP/1.1 made a timeout and throw an error on the app.

Question: Can I control the HTTP protocol? If yes, I would like to set that every request serves on HTTP/2.0 OR HTTP/1.1. I have full control of the IIS Server so I can modify any configuration if It is required. Is something can be done with the TLS1.2 configuration?

UPDATE: I think that I got the root cause of the issue.

Server1: All the requests are using HTTP/2.0 protocol. (Checked IIS logs)

Server2: All the requests are using HTTP/1.1 protocol. (Checked IIS logs) But, still not sure which component is generating a new request for the HTTTP/2.0 protocol on Server2.

Well, I run a curl command and found out a new issue "HTTP/2 stream 0 was not closed cleanly: HTTP_1_1_REQUIRED (err 13)". I think that because of this issue, all the requests are using HTTP/1.1 protocol. If I fix it, all the service will use HTTP/2.0 protocol.

Issue:

enter image description here

Now, how I can fix this server issue? I don't want to handle this into the code. (I mean that specify HTTP protocol in the code)

KiddoDeveloper
  • 568
  • 2
  • 11
  • 34
  • HTTP 1.1 is chunk mode which requires a client to send a next chunk message to server. If next chunk is not sent a timeout will occur. Some clients do not work with 1.1 and you have to use 1.0 (stream mode) instead. – jdweng Jun 13 '21 at 09:19
  • Not understood your comment. Can you please elaborate? – KiddoDeveloper Jun 14 '21 at 06:25
  • You can specify version like this : HttpWebRequest request = (HttpWebRequest)WebRequest.Create(""); request.ProtocolVersion = HttpVersion.Version10; – jdweng Jun 14 '21 at 07:10
  • Actually it's an Ionic app that is making an API request. And, I don't want to specify HTTP version in the code. As my code is working fine on another server. So, I need to resolve a Server specific issue. – KiddoDeveloper Jun 15 '21 at 04:45
  • The server that is working is probably using 1.0 and the new server that is being used is using 1.1. The client is only working with 1.0. So setting to 1.0 will keep code working in same mode that was always being using. A old server does not support 1.1 and the Net client will only work with 1.0. When you go to a new server that defaults to 1.1 and do not specify the version on the client the code doesn't work. – jdweng Jun 15 '21 at 05:05
  • Thanks for the reply. Both servers have the same configurations. Today, I had found something over stackoveflow. That's my issue: https://stackoverflow.com/questions/52388471/iis-10-and-http-2-require-client-certificate – KiddoDeveloper Jun 15 '21 at 05:25
  • The Server That is wokring is using HTTP/2 and that is not working is using HTTP/1.1 – KiddoDeveloper Jun 15 '21 at 05:26
  • The link has nothing to do with your issue except saying the HTTP/2 and HTTP/1.1 will not work in every situation. As I said HTTP/1.1 will not always work with Net (depends on library methods you are using). So Net will work when server defaults to 1.0 and will not work when a server defaults to 1.1. So you have to override the defaults and force 1.0. You could try 2.0 and if fails than try 1.0. See : https://learn.microsoft.com/en-us/uwp/api/windows.web.http.httpversion?view=winrt-20348 – jdweng Jun 15 '21 at 06:00
  • Could you please check HTTP 2.0 is allowed on Server 2? To me it looks like configuration issue on Server2, you could try running failed request module to check why HTTP 2.0 is terminated and 1.0 is used. – mbshambharkar Jun 21 '21 at 19:07
  • @KiddoDeveloper - which server you are using. Try with disabling HTTP/2 on your serve side. IIS Server : https://stackoverflow.com/questions/44660634/how-to-disable-http-2-on-iis-of-windows-server-2016 Apache Server : http://httpd.apache.org/docs/2.4/howto/http2.html – Imran Khan Jun 22 '21 at 03:31
  • @mbshambharkar Yes, I have cross checked. HTTP2.0 is allowed. – KiddoDeveloper Jun 23 '21 at 04:27
  • @ImranKhan I am using Window Server 2016. – KiddoDeveloper Jun 23 '21 at 04:29
  • HTTP 2 relies on SSL internals. If your server is publicly accessible, you can try SSL Labs test to find any certificate errors (https://www.ssllabs.com/ssltest/). If your certificates are self-signed, you can try getting a valid one (zerossl gives free certificates) – Sekhar Jun 23 '21 at 04:29
  • @Sekhar Sorry, my server is not publicly accessible. – KiddoDeveloper Jun 23 '21 at 04:31
  • @KiddoDeveloper, you can use some other tool to install the certificates properly, or may be use https://www.digicert.com/support/tools/certificate-utility-for-windows to check if this can diagnose any ssl issues. You can also try disabling TLS1.1 on the servers – Sekhar Jun 23 '21 at 04:41

0 Answers0