question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to know if the client is using http or http2?

See original GitHub issue

I see in the nginx example that it can listen for both http and http2 calls, given two different ports:

server {
    listen 9091;
    listen 9092 http2;
    server_name localhost;
    location / {
      grpc_pass localhost:9090;
      if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Transfer-Encoding,Custom-Header-1,X-Accept-Content-Transfer-Encoding,X-Accept-Response-Streaming';
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
      }
      if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Transfer-Encoding,Custom-Header-1,X-Accept-Content-Transfer-Encoding,X-Accept-Response-Streaming';
        add_header 'Access-Control-Expose-Headers' 'Content-Transfer-Encoding';
      }
    }
  }

Does it mean that the JS grpc-web client knows how to upgrade to http2 if the given port is http2? If the given port when creating the client is the http one, how the grpc-web client can support the streaming features (server push for example)?

I’m not clear on this point,

thank you for your help!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sulliwanecommented, Mar 28, 2017

Like this ? grpc-web

May I ask why grpc-web is not using “modified grpc over HTTP2” when all browsers support h2?

Finally, if it’s not using h2, I’m curious to know how the server push is implemented over http1.1 (long polling?)

Many thanks

0reactions
sulliwanecommented, Mar 28, 2017

Got it! Many tanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP/2 Test - Verify HTTP/2 Support - KeyCDN Tools
This test can check HTTP and HTTPS but most browsers only support HTTP/2 for HTTPS, which means you must migrate to HTTPS if...
Read more >
How to Confirm HTTP/2 Works on Your Site - ServerPilot
Google Chrome offers a quick and easy way to check if HTTP/2 is supported on your SSL-enabled site. First, visit your site in...
Read more >
Check if HTTP/2 is enabled - Geekflare Tools
Check if the site is taking advantages of the latest HTTP 2 protocol for better content delivery.
Read more >
How to test if your website supports HTTP/2.0 - Edit Agency
To do this, open the Developer toolkit by hitting F12 or right clicking and inspect element in Chrome. Then navigate to the Network...
Read more >
Tools for debugging, testing and using HTTP/2
If you need to test a number of web sites to see which support HTTP/2 there's a tool called h2scan. Feed it a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found