Skip to content
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

Concurrent requests do not work with HTTP/2 #108

Closed
gaborcsardi opened this issue Jan 10, 2025 · 3 comments
Closed

Concurrent requests do not work with HTTP/2 #108

gaborcsardi opened this issue Jan 10, 2025 · 3 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@gaborcsardi
Copy link
Member

web <- webfakes::local_app_process(
  webfakes::httpbin_app(),
  opts = webfakes::server_opts(num_threads = 3)
)

library(testthat)
test_that("", {
  url <- web$url("/delay/1")
  p <- curl::new_pool()
  handles <- replicate(3, curl::new_handle(url = url, http_version = 3))
  resps <- list()
  for (handle in handles) {
    curl::multi_add(
      handle,
      done = function(x) message("one is done"),
      fail = stop,
      pool = p
    )
  }
  st <- system.time(curl::multi_run(timeout = 5, pool = p))
  print(st)
  expect_true(st[["elapsed"]] < 3.0)
})
gaborcsardi added a commit that referenced this issue Jan 10, 2025
Apparently, webfakes parallelism does not work
with HTTP/2 (#108).
@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Jan 10, 2025
@gaborcsardi
Copy link
Member Author

It seems hard to fix this. civetweb does not support HTTP/2 currently, and it is unlikely that it would support it in the future.

Why the behavior is different when client tries HTTP/2 first, I am not sure. Maybe this is something worth reporting to civetweb.

@jeroen
Copy link
Member

jeroen commented Jan 13, 2025

Maybe this is happened because the latest release of curl enabled CURLOPT_PIPEWAIT by default, which does not work well if keepalive is disabled: curl/curl#15838

@gaborcsardi
Copy link
Member Author

gaborcsardi commented Jan 13, 2025

For the record, according to https://curl.se/libcurl/c/CURLOPT_PIPEWAIT.html this is (was) happening, because libcurl does not start another request to the same server until it receives a reply about whether multiplexing is supported or not:

The waiting time is as long as it takes for the connection to get up and for libcurl to get the necessary response back that informs it about its protocol and support level.

I am not sure what exactly this means for HTTP and HTTPS, but if I send the headers quickly, that seems to be enough for HTTP.

EDIT: or maybe not. Nevertheless it is still working with keepalive on, and now I have a test case for it.

gaborcsardi added a commit that referenced this issue Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants