fix(core): reconnection fixes
This commit is contained in:
parent
6b430c5a2a
commit
36abe3defd
2 changed files with 11 additions and 6 deletions
|
@ -37,8 +37,7 @@ export abstract class PersistentConnection {
|
||||||
|
|
||||||
// inactivity timeout
|
// inactivity timeout
|
||||||
private _inactivityTimeout: timers.Timer | null = null
|
private _inactivityTimeout: timers.Timer | null = null
|
||||||
private _inactive = true
|
_inactive = true
|
||||||
|
|
||||||
_destroyed = false
|
_destroyed = false
|
||||||
_usable = false
|
_usable = false
|
||||||
|
|
||||||
|
@ -169,6 +168,11 @@ export abstract class PersistentConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
reconnect(): void {
|
reconnect(): void {
|
||||||
|
if (this._disconnectedManually) {
|
||||||
|
this._disconnectedManually = false
|
||||||
|
this.connect()
|
||||||
|
return
|
||||||
|
}
|
||||||
this._fuman.reconnect(true)
|
this._fuman.reconnect(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +180,7 @@ export abstract class PersistentConnection {
|
||||||
if (this._inactivityTimeout) {
|
if (this._inactivityTimeout) {
|
||||||
timers.clearTimeout(this._inactivityTimeout)
|
timers.clearTimeout(this._inactivityTimeout)
|
||||||
}
|
}
|
||||||
|
this._disconnectedManually = true
|
||||||
await this._fuman.close()
|
await this._fuman.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ export class SessionConnection extends PersistentConnection {
|
||||||
|
|
||||||
if (this._usePfs) {
|
if (this._usePfs) {
|
||||||
if (!this._isPfsBindingPending && this._session._authKeyTemp.ready) {
|
if (!this._isPfsBindingPending && this._session._authKeyTemp.ready) {
|
||||||
this.log.info('transport error 404, reauthorizing pfs')
|
this.log.debug('transport error 404, reauthorizing pfs')
|
||||||
|
|
||||||
// this is important! we must reset temp auth key before
|
// this is important! we must reset temp auth key before
|
||||||
// we proceed with new temp key derivation.
|
// we proceed with new temp key derivation.
|
||||||
|
@ -253,7 +253,7 @@ export class SessionConnection extends PersistentConnection {
|
||||||
|
|
||||||
return
|
return
|
||||||
} else if (this._isPfsBindingPending) {
|
} else if (this._isPfsBindingPending) {
|
||||||
this.log.info('transport error 404, pfs binding in progress')
|
this.log.debug('transport error 404, pfs binding in progress')
|
||||||
|
|
||||||
this._onAllFailed('temp key expired, binding pending')
|
this._onAllFailed('temp key expired, binding pending')
|
||||||
|
|
||||||
|
@ -264,11 +264,10 @@ export class SessionConnection extends PersistentConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
// there happened a little trolling
|
// there happened a little trolling
|
||||||
this.log.info('transport error 404, reauthorizing')
|
this.log.warn('transport error 404, reauthorizing')
|
||||||
this._session.resetAuthKey()
|
this._session.resetAuthKey()
|
||||||
this._resetSession()
|
this._resetSession()
|
||||||
this.onKeyChange.emit(null)
|
this.onKeyChange.emit(null)
|
||||||
this.onError.emit(error)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1488,6 +1487,7 @@ export class SessionConnection extends PersistentConnection {
|
||||||
this._online = online
|
this._online = online
|
||||||
|
|
||||||
if (online) {
|
if (online) {
|
||||||
|
if (this._inactive) return
|
||||||
this.reconnect()
|
this.reconnect()
|
||||||
} else {
|
} else {
|
||||||
this.disconnectManual().catch((err) => {
|
this.disconnectManual().catch((err) => {
|
||||||
|
|
Loading…
Reference in a new issue