Skip to content

Commit

Permalink
fix(tgc): smaller connection backoff elapsed time and multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Apr 6, 2023
1 parent 4a4db08 commit 8c4135e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/internal/tgc/tgc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tgc
import (
"context"
"fmt"
"github.com/cenkalti/backoff/v4"
"github.com/gotd/contrib/middleware/floodwait"
tdclock "github.com/gotd/td/clock"
"github.com/gotd/td/telegram"
Expand Down Expand Up @@ -54,6 +55,14 @@ func New(ctx context.Context, login bool, middlewares ...telegram.Middleware) (*
Resolver: dcs.Plain(dcs.PlainOptions{
Dial: utils.Proxy.GetDial(viper.GetString(consts.FlagProxy)).DialContext,
}),
ReconnectionBackoff: func() backoff.BackOff {
b := backoff.NewExponentialBackOff()

b.Multiplier = 1.1
b.MaxElapsedTime = 30 * time.Second
b.Clock = _clock
return b
},
Device: consts.Device,
SessionStorage: storage.NewSession(kvd, login),
RetryInterval: time.Second,
Expand Down

0 comments on commit 8c4135e

Please sign in to comment.