diff --git a/app/background/node/service.js b/app/background/node/service.js
index b904cbf32..5e42944bd 100644
--- a/app/background/node/service.js
+++ b/app/background/node/service.js
@@ -4,7 +4,6 @@ import { VALID_NETWORKS } from '../../constants/networks';
import path from 'path';
import fs from 'fs';
import crypto from 'crypto';
-import tcpPortUsed from 'tcp-port-used';
import EventEmitter from 'events';
import { NodeClient } from 'hs-client';
import { BigNumber } from 'bignumber.js';
@@ -133,7 +132,18 @@ export class NodeService extends EventEmitter {
switch (conn.type) {
case ConnectionTypes.P2P:
- await this.startNode();
+ try {
+ await this.startNode();
+ } catch (error) {
+ if (error.code === 'EADDRINUSE') {
+ throw new Error(`
+ Could not bind to ${error.address}:${error.port}.
+ Please make sure no other hsd or Bob Wallet instance is running.
+ Quit Bob, and try again.`);
+ } else {
+ throw error;
+ }
+ }
await this.setHSDLocalClient();
dispatchToMainWindow({
type: SET_CUSTOM_RPC_STATUS,
@@ -190,12 +200,6 @@ export class NodeService extends EventEmitter {
return;
}
- const portsFree = await checkHSDPortsFree(this.network);
-
- if (!portsFree) {
- throw new Error('hsd ports in use. Please make sure no other hsd instance is running, quit Bob, and try again.');
- }
-
console.log(`Starting node on ${this.networkName} network.`);
const dir = await this.getDir();
@@ -576,24 +580,6 @@ export class NodeService extends EventEmitter {
}
}
-async function checkHSDPortsFree(network) {
- const ports = [
- network.port,
- network.rpcPort,
- // network.walletPort,
- network.nsPort,
- ];
-
- for (const port of ports) {
- const inUse = await tcpPortUsed.check(port);
- if (inUse) {
- return false;
- }
- }
-
- return true;
-}
-
export const service = new NodeService();
const sName = 'Node';
diff --git a/app/ducks/node.js b/app/ducks/node.js
index 467ee69ed..ecc50178c 100644
--- a/app/ducks/node.js
+++ b/app/ducks/node.js
@@ -11,6 +11,7 @@ import {
SET_FEE_INFO,
SET_CUSTOM_RPC_STATUS,
START_NETWORK_CHANGE,
+ START_ERROR,
STOP,
START_NODE_STATUS_CHANGE,
START_RPC_TEST,
@@ -88,6 +89,7 @@ export const start = (network) => async (dispatch) => {
} catch (error) {
console.error('node start error', error);
dispatch({ type: STOP });
+ dispatch({ type: START_ERROR, payload: error.message });
} finally {
dispatch({ type: END_NODE_STATUS_CHANGE });
}
diff --git a/app/ducks/nodeReducer.js b/app/ducks/nodeReducer.js
index bc4146e87..d1bbae3ec 100644
--- a/app/ducks/nodeReducer.js
+++ b/app/ducks/nodeReducer.js
@@ -84,7 +84,7 @@ export default function nodeReducer(state = getInitialState(), action = {}) {
},
};
case START_ERROR:
- return {...state, error: action.payload.error};
+ return {...state, error: action.payload};
case SET_NODE_INFO:
return {
...state,
diff --git a/app/pages/App/index.js b/app/pages/App/index.js
index 71a5f0dc8..a9f0abdf8 100644
--- a/app/pages/App/index.js
+++ b/app/pages/App/index.js
@@ -302,11 +302,15 @@ const OPEN_ROUTES = [
]
const ProtectedRoute = (props) => {
+ if (OPEN_ROUTES.includes(props.location.pathname)) {
+ return ;
+ }
+
if (!props.wallets.length) {
return ;
}
- if (props.isLocked && !OPEN_ROUTES.includes(props.location.pathname)) {
+ if (props.isLocked) {
return ;
}
diff --git a/package.json b/package.json
index 06d2494e3..14390ffcb 100644
--- a/package.json
+++ b/package.json
@@ -177,7 +177,6 @@
"semver": "^7.3.5",
"shakedex": "https://github.com/chikeichan/shakedex#patch-3",
"source-map-support": "0.5.21",
- "tcp-port-used": "1.0.1",
"uuid": "3.3.3",
"winston": "3.1.0"
}