.catch(() => {
   if (!connection || (!connection.username && !connection.password)) {
     // No creds stored
     store.dispatch(setActiveConnection(null))
     store.dispatch(
       discovery.updateDiscoveryConnection({
         username: '******',
         password: ''
       })
     )
     return resolve({ type: STARTUP_CONNECTION_FAILED })
   }
   bolt
     .openConnection(
       connection,
       { encrypted: getEncryptionMode(connection) },
       onLostConnection(store.dispatch)
     ) // Try with stored creds
     .then(connection => {
       store.dispatch(setActiveConnection(discovery.CONNECTION_ID))
       resolve({ type: STARTUP_CONNECTION_SUCCESS })
     })
     .catch(e => {
       store.dispatch(setActiveConnection(null))
       store.dispatch(
         discovery.updateDiscoveryConnection({
           username: '******',
           password: ''
         })
       )
       resolve({ type: STARTUP_CONNECTION_FAILED })
     })
 })
 return action$.ofType(CONNECT).mergeMap(action => {
   if (!action.$$responseChannel) return Rx.Observable.of(null)
   memoryUsername = ''
   memoryPassword = ''
   return bolt
     .openConnection(action, { encrypted: getEncryptionMode(action) })
     .then(res => ({ type: action.$$responseChannel, success: true }))
     .catch(e => ({
       type: action.$$responseChannel,
       success: false,
       error: e
     }))
 })
 .then(s => {
   bolt.closeConnection()
   bolt
     .openConnection(
       connection,
       { encrypted: getEncryptionMode(connection) },
       onLostConnection(store.dispatch)
     )
     .then(() => {
       store.dispatch(updateConnectionState(CONNECTED_STATE))
       resolve({ type: 'Success' })
     })
     .catch(e => reject(new Error('Error on connect')))
 })
 return new Promise((resolve, reject) => {
   bolt
     .directConnect(
       connection,
       { encrypted: getEncryptionMode(connection) },
       e =>
         setTimeout(
           () => reject(new Error('Couldnt reconnect. Lost.')),
           5000
         )
     )
     .then(s => {
       bolt.closeConnection()
       bolt
         .openConnection(
           connection,
           { encrypted: getEncryptionMode(connection) },
           onLostConnection(store.dispatch)
         )
         .then(() => {
           store.dispatch(updateConnectionState(CONNECTED_STATE))
           resolve({ type: 'Success' })
         })
         .catch(e => reject(new Error('Error on connect')))
     })
     .catch(e => {
       // Don't retry if auth failed
       if (e.code === 'Neo.ClientError.Security.Unauthorized') {
         resolve({ type: e.code })
       } else {
         setTimeout(
           () => reject(new Error('Couldnt reconnect.')),
           5000
         )
       }
     })
 })