fixed SSH reconnection behaviour - fixed #3446, fixed #3442

This commit is contained in:
Eugene Pankov
2021-02-13 12:42:15 +01:00
parent 9734830a74
commit a8c7134218
4 changed files with 23 additions and 19 deletions

View File

@@ -1,10 +1,10 @@
.tab-toolbar .tab-toolbar([class.show]='!session || !session.open')
.btn.btn-outline-secondary.reveal-button .btn.btn-outline-secondary.reveal-button
i.fas.fa-ellipsis-h i.fas.fa-ellipsis-h
.toolbar([class.show]='!session || !session.open') .toolbar
i.fas.fa-circle.text-success.mr-2(*ngIf='session && session.open') i.fas.fa-circle.text-success.mr-2(*ngIf='session && session.open')
i.fas.fa-circle.text-danger.mr-2(*ngIf='!session || !session.open') i.fas.fa-circle.text-danger.mr-2(*ngIf='!session || !session.open')
strong(*ngIf='session') {{session.connection.port}} ({{session.connection.baudrate}}) strong {{connection.port}} ({{connection.baudrate}})
.mr-auto .mr-auto

View File

@@ -97,11 +97,13 @@ export class SerialTabComponent extends BaseTerminalTabComponent {
})) }))
this.attachSessionHandler(this.session!.destroyed$.subscribe(() => { this.attachSessionHandler(this.session!.destroyed$.subscribe(() => {
this.write('Press any key to reconnect\r\n') this.write('Press any key to reconnect\r\n')
setTimeout(() => {
this.input$.pipe(first()).subscribe(() => { this.input$.pipe(first()).subscribe(() => {
if (!this.session?.open) { if (!this.session?.open) {
this.reconnect() this.reconnect()
} }
}) })
}, 100)
})) }))
super.attachSessionHandlers() super.attachSessionHandlers()
} }

View File

@@ -1,14 +1,14 @@
.tab-toolbar .tab-toolbar([class.show]='!session || !session.open')
.btn.btn-outline-secondary.reveal-button .btn.btn-outline-secondary.reveal-button
i.fas.fa-ellipsis-h i.fas.fa-ellipsis-h
.toolbar(*ngIf='session', [class.show]='!session.open') .toolbar
i.fas.fa-circle.text-success.mr-2(*ngIf='session.open') i.fas.fa-circle.text-success.mr-2(*ngIf='session && session.open')
i.fas.fa-circle.text-danger.mr-2(*ngIf='!session.open') i.fas.fa-circle.text-danger.mr-2(*ngIf='!session || !session.open')
strong.mr-auto(*ngIf='session') {{session.connection.user}}@{{session.connection.host}}:{{session.connection.port}} strong.mr-auto {{connection.user}}@{{connection.host}}:{{connection.port}}
button.btn.btn-secondary.mr-2((click)='reconnect()', [class.btn-info]='!session.open') button.btn.btn-secondary.mr-2((click)='reconnect()', [class.btn-info]='!session || !session.open')
span Reconnect span Reconnect
button.btn.btn-secondary((click)='showPortForwarding()', *ngIf='session.open') button.btn.btn-secondary((click)='showPortForwarding()', *ngIf='session && session.open')
i.fas.fa-plug i.fas.fa-plug
span Ports span Ports

View File

@@ -143,7 +143,6 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
protected attachSessionHandlers (): void { protected attachSessionHandlers (): void {
const session = this.session! const session = this.session!
super.attachSessionHandlers()
this.attachSessionHandler(session.destroyed$.subscribe(() => { this.attachSessionHandler(session.destroyed$.subscribe(() => {
if ( if (
// Ctrl-D // Ctrl-D
@@ -158,12 +157,15 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
if (!this.reconnectOffered) { if (!this.reconnectOffered) {
this.reconnectOffered = true this.reconnectOffered = true
this.write('Press any key to reconnect\r\n') this.write('Press any key to reconnect\r\n')
setTimeout(() => {
this.attachSessionHandler(this.input$.pipe(first()).subscribe(() => { this.attachSessionHandler(this.input$.pipe(first()).subscribe(() => {
this.reconnect() this.reconnect()
})) }))
}, 100)
} }
} }
})) }))
super.attachSessionHandlers()
} }
async initializeSession (): Promise<void> { async initializeSession (): Promise<void> {