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

How to change default http protocol version from 0.9 to 1.1 #708

Open
InfiniteLife opened this issue Apr 8, 2024 · 7 comments
Open

How to change default http protocol version from 0.9 to 1.1 #708

InfiniteLife opened this issue Apr 8, 2024 · 7 comments

Comments

@InfiniteLife
Copy link

InfiniteLife commented Apr 8, 2024

I installed prometheus-cpp following instructions from Ubuntu apt. Seems like it only supports HTTP 0.9, because

curl http://127.0.0.1:9090/metrics
returns Received HTTP/0.9 when not allowed
and
curl --http0.9 http://127.0.0.1:9090/metrics works. Is there a way to use HTTP 1.1 protocol?

@gjasny
Copy link
Collaborator

gjasny commented Apr 9, 2024

Hello,

I‘m puzzled because we explicitly write HTTP 1.1 versioned responses. Which Ubuntu version do you use?

Thanks,
Gregor

@gjasny
Copy link
Collaborator

gjasny commented Apr 9, 2024

Could you please run curl with -v and copy the headers of the failed request and response here?

@InfiniteLife
Copy link
Author

Ubuntu 22.04.4 LTS.

curl -v http://127.0.0.1:9090/metrics
*   Trying 127.0.0.1:9090...
* Connected to 127.0.0.1 (127.0.0.1) port 9090 (#0)
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:9090
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Received HTTP/0.9 when not allowed
* Closing connection 0
curl: (1) Received HTTP/0.9 when not allowed
curl -v --http0.9  http://127.0.0.1:9090/metrics
*   Trying 127.0.0.1:9090...
* Connected to 127.0.0.1 (127.0.0.1) port 9090 (#0)
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:9090
> User-Agent: curl/7.81.0
> Accept: */*
> 
# HELP exposer_transferred_bytes_total Transferred bytes to metrics services
# TYPE exposer_transferred_bytes_total counter
exposer_transferred_bytes_total 1612
# HELP exposer_scrapes_total Number of times metrics were scraped
# TYPE exposer_scrapes_total counter
exposer_scrapes_total 2
# HELP exposer_request_latencies Latencies of serving scrape requests, in microseconds
# TYPE exposer_request_latencies summary
exposer_request_latencies_count 2
exposer_request_latencies_sum 694
exposer_request_latencies{quantile="0.5"} 338
exposer_request_latencies{quantile="0.9"} 338
exposer_request_latencies{quantile="0.99"} 338

@InfiniteLife
Copy link
Author

InfiniteLife commented Apr 9, 2024

Could be related, I have also running mongoose webserver on different port in the same app. When I make curl request mongoose seems to be logging some stuff I dont understand:

57660acf 1 mongoose.c:2840:mg_iobuf_res 0->39041252766682
57660acf 1 mongoose.c:2840:mg_iobuf_res 0->39041252766682

Here is function in mongoose.c:

int mg_iobuf_resize(struct mg_iobuf *io, size_t new_size) {
  int ok = 1;
  new_size = roundup(new_size, io->align);
  if (new_size == 0) {
    mg_bzero(io->buf, io->size);
    free(io->buf);
    io->buf = NULL;
    io->len = io->size = 0;
  } else if (new_size != io->size) {
    // NOTE(lsm): do not use realloc here. Use calloc/free only, to ease the
    // porting to some obscure platforms like FreeRTOS
    void *p = calloc(1, new_size);
    if (p != NULL) {
      size_t len = new_size < io->len ? new_size : io->len;
      if (len > 0 && io->buf != NULL) memmove(p, io->buf, len);
      mg_bzero(io->buf, io->size);
      free(io->buf);
      io->buf = (unsigned char *) p;
      io->size = new_size;
    } else {
      ok = 0;
      MG_ERROR(("%lld->%lld", (uint64_t) io->size, (uint64_t) new_size)); // 2840 line here
    }
  }
  return ok;
}

@InfiniteLife
Copy link
Author

I rebuilded my app without creating web server with mongoose, but still am having same log output from mongoose. This gave me suspicion that something smelly goes on in linking, so I completely removed mongoose dependency files from building process. And viola, curl works as it supposed to:


curl -v http://127.0.0.1:9090/metrics
*   Trying 127.0.0.1:9090...
* Connected to 127.0.0.1 (127.0.0.1) port 9090 (#0)
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:9090
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Content-Length: 804
< 

So its definetely linking. But I need that web server on other port too..

@gjasny
Copy link
Collaborator

gjasny commented Apr 9, 2024

I believe civetweb is a fork of mongoose. They share the same symbols and must not be mixed within a process.

@InfiniteLife
Copy link
Author

I see. Is there any docs/example on how to make Exposer use different web server? Like mongoose in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants