Skip to content

Commit

Permalink
Merge pull request #8 from Alethio/v2.4.18
Browse files Browse the repository at this point in the history
V2.4.18
  • Loading branch information
baxy authored Feb 19, 2019
2 parents 75dad65 + f39a4ec commit eb619a3
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 452 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [2.4.18] - 2019-02-18
- Show correct dashboard url when app starts
- Improvements reconnecting with the Ethereum node

## [2.4.17] - 2019-02-17
- Fixed server reconnection bug
- Updated Readme file
Expand Down
20 changes: 13 additions & 7 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,19 @@ export default class Server {
this.log.echo(`${this.pkg.description} v${this.pkg.version} started and running...`);
this.send('connection', {isConnected: true});

this.configurator.get({
configName: 'dashboardUrl'
}).then(value => {
if (value) {
this.log.echo(`Your node is now connected. You can now see your nodes stats/logs at: ${value}`);
}
});
let configStoreServer = this.config.configStore.get('server');
if (configStoreServer && configStoreServer.net !== undefined) {
this.configurator.get({
configName: 'dashboardUrl',
configParams: {
networkName: configStoreServer.net
}
}).then(value => {
if (value) {
this.log.echo(`Your node is now connected. You can now see your nodes stats/logs at: ${value.url}`);
}
});
}

if (!this.pingIntervalId) {
this.pingIntervalId = setInterval(() => {
Expand Down
15 changes: 7 additions & 8 deletions lib/client/protocol/WebSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default class WebSocket extends Abstract {
}

setProvider() {
this.log.debug(`Setting Web3 provider to "${this.url}"`);

if (this.protocol === 'ipc') {
this.web3.setProvider(new Web3.providers.IpcProvider(this.url, net));
} else {
Expand All @@ -40,17 +42,14 @@ export default class WebSocket extends Abstract {
}

connect() {
this.log.echo(`Setting Web3 provider to "${this.url}"`);
this.setProvider();

this.web3.isConnected().then(result => {
if (!result) {
this.log.warning('No connection found with the node. Waiting to connect...');
this.log.echo(`Connecting to node "${this.url}"`);
this.setProvider();
this.checkConnection();
}
});

this.checkConnection();

if (this.connectionInterval === null) {
this.connectionInterval = setInterval(() => {
this.checkConnection();
Expand All @@ -59,9 +58,9 @@ export default class WebSocket extends Abstract {
}

checkConnection() {
this.log.debug('Check connection');

this.web3.isConnected().then(isConnected => {
this.log.debug(`Check node connection => ${isConnected}`);

if (isConnected) {
if (!this.isConnected) {
this.isConnected = true;
Expand Down
Loading

0 comments on commit eb619a3

Please sign in to comment.