Skip to content

Commit

Permalink
fix(exchange): increase exchange timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Feb 16, 2021
1 parent 3b693dd commit 14c1475
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion internal/exchange/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (
"github.com/gotd/td/transport"
)

// DefaultTimeout is default WithTimeout parameter value.
const DefaultTimeout = 1 * time.Minute

// Exchanger is builder for key exchangers.
type Exchanger struct {
conn transport.Conn
Expand Down Expand Up @@ -57,7 +60,7 @@ func NewExchanger(conn transport.Conn) Exchanger {
clock: clock.System,
rand: rand.Reader,
log: zap.NewNop(),
timeout: 15 * time.Second,
timeout: DefaultTimeout,
}
}

Expand Down
3 changes: 2 additions & 1 deletion mtproto/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/gotd/td/bin"
"github.com/gotd/td/clock"
"github.com/gotd/td/internal/crypto"
"github.com/gotd/td/internal/exchange"
"github.com/gotd/td/internal/proto"
"github.com/gotd/td/internal/rpc"
"github.com/gotd/td/internal/tmap"
Expand Down Expand Up @@ -135,7 +136,7 @@ func (opt *Options) setDefaults() {
opt.DialTimeout = 15 * time.Second
}
if opt.ExchangeTimeout == 0 {
opt.ExchangeTimeout = 15 * time.Second
opt.ExchangeTimeout = exchange.DefaultTimeout
}
if opt.MaxRetries == 0 {
opt.MaxRetries = 5
Expand Down

0 comments on commit 14c1475

Please sign in to comment.