hashicorp/raft

"local bind address is not advertisable" in latest `v1.2.0`

jon-whit opened this issue · 6 comments

In v1.1.1 this code worked completely fine:

addr, err := net.ResolveTCPAddr("tcp", ":12000")
if err != nil {
    return err
}

transport, err := raft.NewTCPTransport(":12000", addr, 3, 10*time.Second, os.Stderr)
if err != nil {
    return err // this always returns an error
}

but in v1.2.0 I always get an error returned from the NewTCPTransport call.

I'm using Go 1.15.0

stale commented

Hey there,
We wanted to check in on this request since it has been inactive for at least 90 days.
Have you reviewed the latest godocs?
If you think this is still an important issue in the latest version of the Raft library or
its documentation please feel let us know and we'll keep it open for investigation.
If there is still no activity on this request in 30 days, we will go ahead and close it.
Thank you!

This is still applicable.

Howdy @jon-whit,
Thank you for bringing this up. It seems the error you're running into is from this commit which checks that the address is not nil or unspecified. When I ran the code you provided locally, it seemed that net.ResolveTCPAddr was setting addr to :12000 which is triggering the addr.IP.IsUnspecified(). When I pass in addr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:12000") I no longer see the error.

I'd be interested in hearing about your current use case, and I hope this helps. :)

I met the same issue here, I bind the address to 0.0.0.0:10008 in raft.NewTCPTransport(), I need the raft node to communicate with other raft nodes(my use case).

But I then got errNotAdvertisable = errors.New("local bind address is not advertisable") error.
https://github.com/hashicorp/raft/blob/main/tcp_transport.go#L12

I don't know about the raft, but is it a deliberate design or what? why can't I bind raft to address like 0.0.0.0:10008?

see:
#403
#402

Consider the following code:

	addr, _ := net.ResolveTCPAddr("tcp", ":12322")
	fmt.Printf("%v\n", addr.IP)
	fmt.Printf("%v\n", addr.IP.IsUnspecified())

	addr, _ = net.ResolveTCPAddr("tcp", "0.0.0.0:12322")
	fmt.Printf("%v\n", addr.IP)
	fmt.Printf("%v\n", addr.IP.IsUnspecified())

https://play.golang.org/p/ORSFNb5Bi5d

Which the output

<nil>
false
0.0.0.0
true

The node listening on 0.0.0.0:12322 needs to tell its peers how to reach it, i.e. its address. If the address is unspecified, we don't have a good way of knowing which of potentially many interfaces the user is expecting Raft to communicate on. So yes, this is a deliberate part of the design.

I'm closing this, we can re-open if there's new information.