web3 / web3.js

Collection of comprehensive TypeScript libraries for Interaction with the Ethereum JSON RPC API and utility functions.
https://web3js.org/
Other
19.16k stars 4.91k forks source link

Websocket on 1.0.0-beta.52 (TypeError: The header content contains invalid characters) #2754

Closed gmaijoe closed 4 years ago

gmaijoe commented 5 years ago

Description

I'm getting the following error when reading infura's websocket endpoint on a new Web3 instance.

`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:243:15) at Object.request (/Users/gmaister/Desktop/workspace/Carbon/carbon.js/node_modules/agent-base/patch-core.js:23:20) at WebSocketClient.connect (/Users/gmaister/Desktop/workspace/Carbon/carbon.js/node_modules/websocket/lib/WebSocketClient.js:254:56) at new W3CWebSocket (/Users/gmaister/Desktop/workspace/Carbon/carbon.js/node_modules/websocket/lib/W3CWebSocket.js:62:18) at ProvidersModuleFactory.createWebsocketProvider (/Users/gmaister/Desktop/workspace/Carbon/carbon.js/node_modules/web3-providers/dist/web3-providers.cjs.js:1262:22) at new WebsocketProvider$1 (/Users/gmaister/Desktop/workspace/Carbon/carbon.js/node_modules/web3-providers/dist/web3-providers.cjs.js:1328:39) at Object. (/Users/gmaister/Desktop/workspace/Carbon/carbon.js/Routes/v1/spectrum/util/scanForTransactionETH.js:25:23) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Function._load (/Users/gmaister/Desktop/workspace/Carbon/carbon.js/node_modules/@sentry/node/dist/integrations/console.js:41:47) at Module.require (module.js:597:17) at require (internal/module.js:11:18) at Object. (/Users/gmaister/Desktop/workspace/Carbon/carbon.js/Routes/v1/spectrum/index.js:20:44) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10)

Failed Code Snippet

const networkToUseWS = wss://mainnet.infura.io/ws; console.log(chalk.magenta('url: ', networkToUseWS)); const web3 = new Web3(new Web3.providers.WebsocketProvider(networkToUseWS));

Versions

nivida commented 5 years ago

Could you create a repository to reproduce this?

gmaijoe commented 5 years ago

@nivida i added you to our repo (branch is "spectrum")

nivida commented 5 years ago

Could you add the URL of the repository here?

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions