INFURA / infura

Official Public Repository for INFURA
https://infura.io
381 stars 62 forks source link

WebSocket connection to 'wss://ropsten.infura.io/ws' failed: Received a broken close frame containing a reserved status code. #179

Open rubenrdp opened 5 years ago

rubenrdp commented 5 years ago

After I successfully create my web3 instance using:

window.web3 = new Web3('wss://ropsten.infura.io/ws')

I try invoking a contract method using the send() method in Web3js (1.0.0) but I the error on the title.

Can anybody help with this?

Thanks!

ageyev commented 5 years ago

https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#methods-mymethod-send should not work if you use Infura. You have to use web3.eth.sendSignedTransaction https://web3js.readthedocs.io/en/1.0/web3-eth.html?highlight=signTransaction#sendsignedtransaction

rubenrdp commented 5 years ago

Hi @ageyev, thanks for your comment.

For sometime I suspected the problem was because Infura's API does not support sendTransaction() and only sendSignedTransaction() as you mention. But then I thought that maybe the send() method could be smarter and try create a signed transaction internally and then send it using sendSignedTransaction() rather than trying to invoke sendTransaction() directly. So, I kept searching and found this issue https://github.com/ethereum/web3.js/issues/2569#issuecomment-480566140 where it seems to be a problem with the API.

The problem seems to be fixed on beta50 but my code uses beta36 (the last built version of Web3js) but I don't know where to get the new version from.