Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1854

Reusing connections with reqwest

$
0
0

I need to issue a long sequence of REST calls to the same server (let's call it myapi.com). At the moment, I am using the Rust library reqwest as follows:

  • I create a reqwest::Client with all default settings.
  • For each REST call:
    • I use client.post("https://myapi.com/path/to/the/api") to create a reqwest::RequestBuilder.
    • I configure the RequestBuilder to obtain a reqwest::Request.
    • I send() the Request, read the reqwest::Response.
    • I drop everything except the Client, start again.

I read in the docs that reqwest is supposed to pool connections within the same Client. Given that I always reuse the same Client, I would expect the first API call to take some more (owing to the initial TCP and HTTPS handshakes). However, I observe always a consistent, quite high latency across all requests. So, I am wondering if connections are reused at all, or re-established every time. If they are not, how do I get to recycle the same connection? I feel that latency would be drastically reduced if I could save myself some roundtrips.


Viewing all articles
Browse latest Browse all 1854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>