1

Trying to connect to a geth machine over websocket? JS code.

var Web3=require('web3');
var web3 = new Web3(new 
Web3.providers.WebsocketProvider('ws://10.244.5.43:8546'));
console.log(web3.isConnected());

Not sure how to connect using WebSocket?

1

I assume that you're using a version of Web3.js older than 1.0. I believe that the WebsocketProvider was added in 1.0.

| improve this answer | |
1

I had the same issue with web3 v1.0.0 beta 30. Never got to the bottom of it but skipping the provider construction appeared to fix it:

var Web3=require('web3');
var web3 = new Web3('ws://10.244.5.43:8546');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.