-
Notifications
You must be signed in to change notification settings - Fork 28
Conversation
Is it worth exposing a way to tune keep-alive interval? |
Ideally, this should just work. In practice, I expect this to be platform-dependent (and dependent on your NAT, of course). We don't really have a good way to measure the effects of different values at this point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely need a way to set the keepalive interval.
Many residential NATs reset the stream faster than the default 75s interval.
@vyzo How do you suggest we do that? Should we use a shorter value here, or do we want to expose an API for that? Would it be a good idea to only enable keepalives if we're behind a NAT? |
Not clear how to best do it. |
I'm not really sure how to implement with without violating our layers here. |
Yeah, it's tricky business. Maybe we can utilize the event bus? @Stebalien thoughts? |
15s seems really short. Do we have any data on this? I'd rather just set it to every 30s and leave it at that if it works for us. I mean, the right way to do this is to learn, but that's hard:
But it's much simpler to just pick 30s and be done with it. The overhead should be almost nothing. |
Fair enough, let's just do that. If we get reports of connections crapping out, we can consider reducing it (or provide some interface to do so). Re: data That's just empirical at that point, and I have also seen it mentioned in NAT traversal papers. |
b7c7941
to
33b59b8
Compare
log.Errorf("Can't set TCP keepalives.") | ||
} | ||
if err := keepAliveConn.SetKeepAlive(keepAlive); err != nil { | ||
log.Errorf("Failed to enable TCP keepalive: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to start off with an error, but this may have false positives (e.g., connection closed?). However, I assume that this method won't fail until we actually call close
ourselves.
Also, return?
33b59b8
to
50ea0f3
Compare
Since this shouldn't be the responsibility of the stream muxer any more, see libp2p/go-yamux#44.