Skip to content

Commit ac7db6a

Browse files
committed
Revert "fix: try lowering the chance of hangup"
This reverts commit f621c72.
1 parent 49ac6a9 commit ac7db6a

File tree

4 files changed

+9
-22
lines changed

4 files changed

+9
-22
lines changed

internal/mtproto/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ func (opt *Options) setDefaults() {
131131
opt.SaltFetchInterval = 1 * time.Hour
132132
}
133133
if opt.PingTimeout == 0 {
134-
opt.PingTimeout = 10 * time.Second
134+
opt.PingTimeout = 15 * time.Second
135135
}
136136
if opt.PingInterval == 0 {
137-
opt.PingInterval = 15 * time.Second
137+
opt.PingInterval = 1 * time.Minute
138138
}
139139
if opt.RequestTimeout == nil {
140140
opt.RequestTimeout = func(req uint32) time.Duration {

telegram/connect.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ func (c *Client) runUntilRestart(ctx context.Context) error {
2222
if !c.noUpdatesMode {
2323
g.Go(func(ctx context.Context) error {
2424
// Call method which requires authorization, to subscribe for updates.
25-
// See https://core.telegram.org/api/updates#subscribing-to-updates
26-
c.log.Debug("Calling c.Self to subscribe for updates")
25+
// See https://core.telegram.org/api/updates#subscribing-to-updates.
2726
self, err := c.Self(ctx)
2827
if err != nil {
2928
// Ignore unauthorized errors.
@@ -59,29 +58,21 @@ func (c *Client) isPermanentError(err error) bool {
5958
}
6059

6160
func (c *Client) reconnectUntilClosed(ctx context.Context) error {
61+
// Note that we currently have no timeout on connection, so this is
62+
// potentially eternal.
6263
b := tdsync.SyncBackoff(backoff.WithContext(c.connBackoff(), ctx))
6364

6465
return backoff.RetryNotify(func() error {
6566
if err := c.runUntilRestart(ctx); err != nil {
66-
if ctxErr := ctx.Err(); ctxErr != nil {
67-
c.log.Error("Stopping reconnection attempts due to parent context error",
68-
zap.Error(err),
69-
zap.Errors("error_parent", []error{ctxErr}),
70-
)
71-
return errors.Wrap(err, "parent context closed")
72-
}
7367
if c.isPermanentError(err) {
7468
return backoff.Permanent(err)
7569
}
76-
return errors.Wrap(err, "runUntilRestart")
70+
return err
7771
}
7872

7973
return nil
8074
}, b, func(err error, timeout time.Duration) {
81-
c.log.Info("Restarting connection",
82-
zap.Error(err),
83-
zap.Duration("backoff", timeout),
84-
)
75+
c.log.Info("Restarting connection", zap.Error(err), zap.Duration("backoff", timeout))
8576

8677
c.connMux.Lock()
8778
c.conn = c.createPrimaryConn(nil)

telegram/internal/manager/conn.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,10 @@ func (c *Conn) Run(ctx context.Context) (err error) {
123123
defer func() {
124124
if err != nil && ctx.Err() == nil {
125125
c.log.Debug("Connection dead", zap.Error(err))
126-
} else {
127-
c.log.Debug("Connection closed")
128126
}
129127
}()
130128
return c.proto.Run(ctx, func(ctx context.Context) error {
131-
// Signal death on init error. Otherwise, connection shutdown
129+
// Signal death on init error. Otherwise connection shutdown
132130
// deadlocks in OnSession that occurs before init fails.
133131
err := c.init(ctx)
134132
if err != nil {

telegram/options.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ func defaultBackoff(c clock.Clock) func() backoff.BackOff {
153153
return func() backoff.BackOff {
154154
b := backoff.NewExponentialBackOff()
155155
b.Clock = c
156-
b.MaxElapsedTime = time.Minute
157-
b.InitialInterval = time.Millisecond * 100
158-
b.MaxInterval = time.Second
156+
b.MaxElapsedTime = 0
159157
return b
160158
}
161159
}

0 commit comments

Comments
 (0)