Skip to content

[hyper-util] HttpConnector::set_local_address interacts weirdly with HttpConnector::set_happy_eyeballs_timeout #4258

Open
hyperium/hyper-util
#346

Description

@Scripter17

Version

hyper-util 0.1.21

Platform

Kubuntu 26.04, Linux 7.0.0

Summary

HttpConnector::set_local_address states that all sockets are bound to the provided IpAddr. This is mostly true, except for when setting HttpConnector::set_happy_eyeballs_timeout to None.

Code Sample

use hyper_util::client::legacy::{Client, connect::HttpConnector};
use hyper_util::rt::TokioExecutor;

#[tokio::main]
async fn main() {
    let mut connector = HttpConnector::new();

    connector.set_local_address(Some("::1".parse().unwrap()));

    connector.set_happy_eyeballs_timeout(None);

    let client = Client::builder(TokioExecutor::new()).build::<_, String>(connector);

    // 104.20.23.154 = example.com
    println!("{:?}", client.get("http://104.20.23.154".parse().unwrap()).await.unwrap());
}

Expected Behavior

A panic, since connecting to an IPv4 address with a socket bound to the IPv6 loopback address shouldn't work. At least it doesn't with the IPv4 loopback address.

Actual Behavior

A successful connection.

Additional Context

The culprit seems to be client::legacy::connect::http::ConnectingTcp::new where sockets of the wrong IP version are discarded if and only if the happy eyeballs timeout is Some.

Though since it would be extremely weird to write it like that by accident I might be misunderstanding something.

At the very least, it seems the docs of HttpConnector::set_local_address isn't correct.

Activity

  1. added
    C-bugCategory: bug. Something is wrong. This is bad!
    on Nov 6, 2026
  2. akasakariko commented on Nov 6, 2026

    @akasakariko
    Contributor

    I'd like to work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug. Something is wrong. This is bad!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions