-
-
Notifications
You must be signed in to change notification settings - Fork 839
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
Support HTTP/2 prior-knowledge, using httpx.Client(http1=False, http2=True)
.
#1624
Conversation
Okay, so design question here... I guess we might want to be using But I'm not completely sure if we want to prefer that or |
Okay, so I'm okay with this. Couple of things...
|
httpx.Client(http1=False)
.
httpx.Client(http1=False)
.httpx.Client(http1=False, http2=True)
.
The main reason for this patch was to enforce HTTP/2 usage. There was no need for different handliong of HTTP/1 and HTTP/1.1. |
Great, thanks! |
Hi @tomchristie I am using httpx.Client(http2=True, http1=False) for one request is working, but I am not able to send multiple request for the same connection. What I am sure about that the issue is related to the stream Id, but how can I initiate multiple request with different stream id in the same connection for http2? Thank you |
Can you show us what you're seeing? |
Hi @tomchristie this is the code which is working for one http/2 request but not multiple: start_time = time.time() async def Asyncmain(clients): if name == 'main': The error I got: Traceback (most recent call last): The above exception was the direct cause of the following exception: Traceback (most recent call last): I tried a lot of way to initiate the AsyncClient and Client, inside the loop and outside the loop and I am still facing this issue. Your help is much appreciated. |
So, first up... simplify things way down, as simple as you can... client = httpx.Client(http1=False, http2=True)
r = client.get(url)
print(r)
r = client.get(url)
print(r) Does this still raise the exception, or not? (Also is this a public URL?) |
No, It's not a public URL. client = httpx.Client( http2=True, http1=False)
|
What server are you working against? |
The server is Apache | Ubuntu. Yeah, for http1.1 is working but Http/2 should have different stream Id. so when I am trying to send multiple request still facing this issue. |
Well, first pass answer is - don't use HTTP/2. (It's not gaining you anything) (Unless you've got a good reason to do so, probably also don't use async, but that's a different story) Why is the server disconnecting after the first request... don't know - really very hard for me to be able to dig into if it's something I'm not able to replicate. It'd be helpful for us at some point to add enough logging that you're able to fully inspect all the frames in both directions, but we don't have that at the moment. |
Http1.1 does not give me the ability to send multiple request in parallel or open multiple TCP connection, that's why I was trying to send this request. Thank you so much for your help |
Sure, this sort of thing works fine... import httpx
client = httpx.Client(http2=True)
r = client.get("https://www.example.com")
print(r, r.http_version)
r = client.get("https://www.example.com")
print(r, r.http_version) A sensible approach would be to really really narrow down your example until you've got something absolutely trivial that you can share as the simplest possible case that reproduces the error. Ideally you'd want to try the code against some other HTTP/2 server so you can try to narrow down if you're seeing a client issue or a server issue. (But again, if you want an easy life here - just use HTTP/1.1. Really.) |
This pull request is related to httpcore pull request 269.
New parameter 'http1' is passed through to httpcore.
Both changes are used in robotframework-httpx that provides HTTP/2 support for Robotframework.
Edit from @tomchristie: Refs #503