You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let nodeUrl = "wss://" + USER + ":" + PASS + "@" + WSS_ENDPOINT;
// let provider = new Web3.providers.WebsocketProvider(nodeUrl);
let web3 = new Web3(new Web3.providers.WebsocketProvider(nodeUrl))
// Now you can call web3 functions, so we'll just test the connection by getting the latest block in the chain.
web3.eth.getBlock("latest").then((latestBlock) => {
console.log("Latest Block Via Websocket Provider: ");
console.log(latestBlock);
}).catch((er)=>{
console.log("error",er)
})
This code snippet results in following error:-
http_outgoing.js:494
throw new TypeError('The header content contains invalid characters');
^
TypeError: The header content contains invalid characters
at validateHeader (_http_outgoing.js:494:11)
at ClientRequest.setHeader (_http_outgoing.js:498:3)
at new ClientRequest (_http_client.js:173:14)
at Object.request (http.js:38:10)
at Object.request (https.js:239:15)
at WebSocketClient.connect (/home/himanshu/kafkaTest/web3Listener/node_modules/websocket/lib/WebSocketClient.js:241:56)
at new W3CWebSocket (/home/himanshu/kafkaTest/web3Listener/node_modules/websocket/lib/W3CWebSocket.js:62:18)
at ProvidersModuleFactory.createWebsocketProvider (/home/himanshu/kafkaTest/web3Listener/node_modules/web3-providers/dist/web3-providers.cjs.js:1254:22)
at new WebsocketProvider (/home/himanshu/kafkaTest/web3Listener/node_modules/web3-providers/dist/web3-providers.cjs.js:1295:39)
at Object. (/home/himanshu/kafkaTest/web3Listener/index.js:98:22)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
Same code snippet runs when i replace kaleido url with rinkeby websocket url of infura.
Please Help!!!
The text was updated successfully, but these errors were encountered:
himanshuchawla009
changed the title
Not able to use web sockets with web3.
Not able to use web sockets with web3 js.
Mar 9, 2019
let nodeUrl = "wss://" + USER + ":" + PASS + "@" + WSS_ENDPOINT;
// let provider = new Web3.providers.WebsocketProvider(nodeUrl);
let web3 = new Web3(new Web3.providers.WebsocketProvider(nodeUrl))
// Now you can call web3 functions, so we'll just test the connection by getting the latest block in the chain.
web3.eth.getBlock("latest").then((latestBlock) => {
console.log("Latest Block Via Websocket Provider: ");
console.log(latestBlock);
}).catch((er)=>{
console.log("error",er)
})
This code snippet results in following error:-
http_outgoing.js:494
throw new TypeError('The header content contains invalid characters');
^
TypeError: The header content contains invalid characters
at validateHeader (_http_outgoing.js:494:11)
at ClientRequest.setHeader (_http_outgoing.js:498:3)
at new ClientRequest (_http_client.js:173:14)
at Object.request (http.js:38:10)
at Object.request (https.js:239:15)
at WebSocketClient.connect (/home/himanshu/kafkaTest/web3Listener/node_modules/websocket/lib/WebSocketClient.js:241:56)
at new W3CWebSocket (/home/himanshu/kafkaTest/web3Listener/node_modules/websocket/lib/W3CWebSocket.js:62:18)
at ProvidersModuleFactory.createWebsocketProvider (/home/himanshu/kafkaTest/web3Listener/node_modules/web3-providers/dist/web3-providers.cjs.js:1254:22)
at new WebsocketProvider (/home/himanshu/kafkaTest/web3Listener/node_modules/web3-providers/dist/web3-providers.cjs.js:1295:39)
at Object. (/home/himanshu/kafkaTest/web3Listener/index.js:98:22)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
Same code snippet runs when i replace kaleido url with rinkeby websocket url of infura.
Please Help!!!
The text was updated successfully, but these errors were encountered: