@@ -8,6 +8,7 @@ import _ from 'lodash';
88const actions = {
99 connect ( config ) {
1010 return dispatch => {
11+ let sshErrorThrown = false
1112 if ( config . ssh ) {
1213 dispatch ( { type : 'updateConnectStatus' , data : 'SSH connecting...' } ) ;
1314 const conn = new Client ( ) ;
@@ -25,26 +26,26 @@ const actions = {
2526 } ) ;
2627 } )
2728 . on ( 'error' , err => {
29+ sshErrorThrown = true
2830 dispatch ( { type : 'disconnect' } ) ;
2931 alert ( `SSH Error: ${ err . message } ` ) ;
3032 } ) ;
3133
3234 try {
35+ const connectionConfig = {
36+ host : config . sshHost ,
37+ port : config . sshPort || 22 ,
38+ username : config . sshUser
39+ }
3340 if ( config . sshKey ) {
34- conn . connect ( {
35- host : config . sshHost ,
36- port : config . sshPort || 22 ,
37- username : config . sshUser ,
41+ conn . connect ( Object . assign ( connectionConfig , {
3842 privateKey : config . sshKey ,
3943 passphrase : config . sshKeyPassphrase
40- } ) ;
44+ } ) ) ;
4145 } else {
42- conn . connect ( {
43- host : config . sshHost ,
44- port : config . sshPort || 22 ,
45- username : config . sshUser ,
46+ conn . connect ( Object . assign ( connectionConfig , {
4647 password : config . sshPassword
47- } ) ;
48+ } ) ) ;
4849 }
4950 } catch ( err ) {
5051 dispatch ( { type : 'disconnect' } ) ;
@@ -98,7 +99,9 @@ const actions = {
9899 } ) ;
99100 redis . once ( 'end' , function ( ) {
100101 dispatch ( { type : 'disconnect' } ) ;
101- alert ( 'Redis Error: Connection failed' ) ;
102+ if ( ! sshErrorThrown ) {
103+ alert ( 'Redis Error: Connection failed' ) ;
104+ }
102105 } ) ;
103106 }
104107 } ;
0 commit comments