Skip to content
This repository was archived by the owner on May 11, 2022. It is now read-only.

Fix: Stream read timeout #99

Merged
merged 1 commit into from
Feb 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
manet "github.com/multiformats/go-multiaddr/net"
)

var streamReadTimeout = 60 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get timeout in one place, so it can be set as a config option by a consumer consistently, rather than being defined in each sub module as a variable that can't be changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willscott That change will need changes across submodules now. Please can we merge this and this later ? Have created a follow-up issue at libp2p/go-libp2p#1035 and assigned it to myself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup. just wanted to raise that the downside is now it's basically impossible to change this


// AutoNATService provides NAT autodetection services to other peers
type autoNATService struct {
ctx context.Context
Expand Down Expand Up @@ -50,6 +52,8 @@ func newAutoNATService(ctx context.Context, c *config) (*autoNATService, error)
}

func (as *autoNATService) handleStream(s network.Stream) {
s.SetReadDeadline(time.Now().Add(streamReadTimeout))

defer s.Close()

pid := s.Conn().RemotePeer()
Expand Down