Skip to content

Commit

Permalink
Fixed web3 WebSocketProvider connection issue
Browse files Browse the repository at this point in the history
  • Loading branch information
baxy committed Feb 14, 2019
1 parent 6518c53 commit aa53246
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## [2.4.16] - 2019-02-14
- Fixed web3 WebSocketProvider connection issue

## [2.4.14] - 2019-02-12
- Reconnect to server improvements
- Reinit web3 improvements when no new block received
Expand Down
12 changes: 8 additions & 4 deletions lib/client/protocol/WebSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ export default class WebSocket extends Abstract {
constructor(diContainer) {
super(diContainer);

this.web3 = null;
}

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

setProvider() {
if (this.protocol === 'ipc') {
this.web3.setProvider(new Web3.providers.IpcProvider(this.url, net));
} else {
this.web3.setProvider(new Web3.providers.WebsocketProvider(this.url));
}
}

connect() {
this.log.echo(`Setting Web3 provider to "${this.url}"`);
this.setProvider();
Expand Down
47 changes: 21 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethstats-cli",
"version": "2.4.14",
"version": "2.4.16",
"description": "EthStats - Network Monitor - CLI Client (net.ethstats.io)",
"homepage": "https://github.com/alethio/ethstats-cli",
"author": {
Expand Down

0 comments on commit aa53246

Please sign in to comment.