简体   繁体   English

对于Kaleido使用Websocket连接时,“ send()上的连接未打开”错误

[英]“connection not open on send()” error when using Websocket connection for Kaleido

I get a 'connection not open on send()' error immediately after connecting to a Websocket for a Kaleido node. 连接到Kaleido节点的Websocket后,我立即收到“在send()上未打开连接”错误。 I am trying to use the WebsocketProvider from web3js version 1.0.0-beta.34. 我正在尝试使用来自web3js版本1.0.0-beta.34的WebsocketProvider。

My code for the connection looks like this, where username , password and wssUrl are local variables with the information about the Kaleido node. 我的连接代码如下所示,其中usernamepasswordwssUrl是包含有关Kaleido节点信息的局部变量。

const web3 = new Web3(new Web3.providers.WebsocketProvider(`wss://${username}:${password}@${wssUrl}`))

I've tried the suggested steps listed in this Github issue -- trying to reconnect if the connection is lost, but the error still persists. 我尝试了此Github问题中列出的建议步骤-如果连接断开,尝试重新连接,但错误仍然存​​在。 I think it may be a Kaleido issue as I'm able to use the WebsocketProvider for a local Ganache account. 我认为这可能是Kaleido的问题,因为我可以将WebsocketProvider用于本地Ganache帐户。

It would be helpful to be able to use the Websocket connection for a Kaleido node, so I can use web3js version 1.0. 能够将Websocket连接用于Kaleido节点将很有帮助,因此我可以使用web3js版本1.0。 The HTTP connection works just fine, but in web3js 1.0 listening for events with the HttpProvider is deprecated, thus forcing you to use the WebsocketProvider. HTTP连接工作正常,但是在web3js 1.0中,不建议使用HttpProvider侦听事件,因此强制您使用WebsocketProvider。 Thanks! 谢谢!

Update 更新资料

web3js 1.0.0-beta.34 will fallback to Node JS's legacy URL parser. web3js 1.0.0-beta.34将回退到Node JS的旧版URL解析器。 Changes have already been delivered to the 1.0 branch of ethereum/web3.js to remedy this issue. 更改已经交付到ethereum / web3.js的1.0分支来解决此问题。

To work around this: 要变通解决此问题:

npm i -g lerna
npm i https://github.com/ethereum/web3.js.git\#1.0

lerna is just a build tool that the web3 project relies on during development. lerna只是web3项目在开发过程中依赖的构建工具。


I just watched the Wireshark log for this request and it seems web3js is not passing the basic Authn headers during the WebSocket upgrade request. 我只是看着Wireshark日志中的请求,似乎web3js在WebSocket升级请求中没有传递基本的Authn标头。

GET / HTTP/1.1 
Upgrade: websocket 
Connection: Upgrade 
Sec-WebSocket-Version: 13 
Sec-WebSocket-Key: XXXX==
Host: zzzzz-zzzzz-wss.us-east-2.kaleido.io 

One might, think that Sec-WebSocket-Key is an Authn header, but it's really a protocol countermeasure for another sort of attack. 可能有人认为Sec-WebSocket-Key是Authn标头,但这实际上是另一种攻击的协议对策。 You can read more at this quesiton: What is Sec-WebSocket-Key for? 您可以在以下问题上阅读更多内容: Sec-WebSocket-Key的作用是什么?

I'll take a look and see if I can hack together a patch to get this working. 我来看一下是否可以破解补丁才能正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 web3.js 中的连接超时 - Connection timeouts in web3.js 侦听 node.js 中的事件时,“远程对等方断开连接” - 'Connection dropped by remote peer' when listening on event in node.js 什么是币安web插座连接URL? - What is the Binance web socket connection URL? 将web3.js与Jest一起使用时出错 - Error when using web3.js with Jest 使用 web3js1.0 发送交易:错误:无效的 JSON RPC 响应:“” - Send a transaction using web3js1.0: Error: Invalid JSON RPC response: “” 当我尝试使用 biconomy 从 web3 发送交易时出现这种类型的错误 - Getting this types of err when i am trying to send transaction from web3 using biconomy 我在 Metamask 'Unchecked runtime.lastError: 无法建立连接'上遇到错误 - I got error on Metamask 'Unchecked runtime.lastError: Could not establish connection' 我正在尝试发送交易,但它会引发错误 - i am trying to send a transaction but it throws an error 使用松露牢固地调用函数时出现新的BigNumber()错误。 如何解决错误? - Getting new BigNumber() error when calling a function in solidity using truffle. How do I fix the error? 坚固性0.4.6中使用send()函数时,合同抛出无效地址 - Contract throws Invalid address when using send() function in solidity 0.4.6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM