Http2.0 FRAME_SIZE_ERROR What doest that mean?

Hey everyone trying to use http2 procotol with h2 crate and getting this error: Error: Error { kind: GoAway(b"", FRAME_SIZE_ERROR, Library) }
What can be wrong ?

Here is the example code that im using:

use h2::client;
use http::{HeaderMap, Request, Method,};
use std::error::Error;
use tokio::net::TcpStream;

pub async fn main() -> Result<(), Box<dyn Error>> {
    // Establish TCP connection to the server.
    let tcp = TcpStream::connect("<ip>:443").await?;
    let (h2, connection) = client::handshake(tcp).await?;
    tokio::spawn(async move {

    let mut h2 = h2.ready().await?;
    // Prepare the HTTP request to send to the server.
    let request = Request::builder()
    .header("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36")

    // Send the request. The second tuple item allows the caller
    // to stream a request body.
    let (response, _) = h2.send_request(request, true).unwrap();

    let (head, mut body) = response.await?.into_parts();

    println!("Received response: {:?}", head);

    // The `flow_control` handle allows the caller to manage
    // flow control.
    // Whenever data is received, the caller is responsible for
    // releasing capacity back to the server once it has freed
    // the data from memory.
    let mut flow_control = body.flow_control().clone();

    while let Some(chunk) = {
        let chunk = chunk?;
        println!("RX: {:?}", chunk);

        // Let the server send more data.
        let _ = flow_control.release_capacity(chunk.len());


Are you sure the server you're connecting to is assuming HTTP/2? h2 doesn't handle upgrading from HTTP/1.1 as documented under Handshake

I have checked over console tab XHR and saw that there was writing h3 procotol so i assume must be supported h2 if h3 support exists

There are multiple ways for your browser to indicate protocol support, but the code you wrote isn't using any of them. Is there a reason you're using h2 as opposed to an HTTP client like reqwest?

I have tried to use reqwest first by using ClientBuilder in reqwest - Rust
this method allowing for only http2 and got same error when i use reqwest and then moved the h2 library and again got this frame_size_error in h2 library too.
So i got same error for both library

Why are you trying to force HTTP/2?

To me that strongly suggests the server you're connecting to supports HTTP/1.1 and requires an upgrade mechanism to select a newer version.

I just want to see the performance difference between h1-2-3 protocols.

You can enable the ALPN feature of reqwest and set the HTTP version on the RequestBuilder.


tokio = { version = "1.20.1", features = ["full"] }
reqwest = {version = "0.11.11", features = ["native-tls-alpn"]}

use reqwest::{Client, Version};

async fn main() {
    let client = Client::new();

    let response = client
        // Causes an runtime error without native-tls-alpn feature

    assert_eq!(response.version(), Version::HTTP_2);
    println!("{:?}", response.version());
    println!("{:#?}", response)


Response {
    url: Url {
        scheme: "https",
        cannot_be_a_base: false,
        username: "",
        password: None,
        host: Some(
        port: None,
        path: "/",
        query: None,
        fragment: None,
    status: 200,
    headers: {
        "date": "Sun, 11 Sep 2022 20:10:21 GMT",
        "expires": "-1",
        "cache-control": "private, max-age=0",
        "content-type": "text/html; charset=ISO-8859-1",
        // (and a bunch of other junk)
1 Like

eyy awesome i wasnt expecting easy that much thanks a lot