Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event Listener Error: connection not open on send() #1237

Open
ARR552 opened this issue Jul 19, 2020 · 7 comments
Open

Event Listener Error: connection not open on send() #1237

ARR552 opened this issue Jul 19, 2020 · 7 comments
Labels
bug Something isn't working icebox items that need more consideration, time, or can wait P4 Low (ex: Node doesn't start up when the configuration file has unexpected "end-of-line" character)

Comments

@ARR552
Copy link

ARR552 commented Jul 19, 2020

Hello,
I'm trying to read events in real time (Not past events). The docker compose is:

bootnode:
build:
context: besu/.
args:
BESU_VERSION: ${BESU_VERSION}
image: sample-network/besu:${BESU_VERSION}
environment:
- BESU_PUBLIC_KEY_DIRECTORY=${BESU_PUBLIC_KEY_DIRECTORY}
entrypoint: /opt/besu/bootnode_start.sh
command: &base_options [
"--config-file=/config/config.toml",
"--genesis-file=/config/genesis.json",
"--node-private-key-file=/opt/besu/keys/key",
"--min-gas-price=0",
"--rpc-ws-enabled",
"--rpc-http-api=WEB3,ETH,NET,EEA,ADMIN,${SAMPLE_POA_API-ibft}",
"--rpc-ws-api=WEB3,ETH,NET,EEA,ADMIN,${SAMPLE_POA_API-ibft}"]
volumes:
- public-keys:${BESU_PUBLIC_KEY_DIRECTORY}
- ./config/besu/config.toml:/config/config.toml
- ./config/besu/${SAMPLE_POA_NAME-ibft2}Genesis.json:/config/genesis.json
- ./config/besu/networkFiles/bootnode/keys:/opt/besu/keys

The config.toml has this content:

logging="INFO"
data-path="/opt/besu/data"
host-whitelist=["*"]

rpc-http-enabled=true
rpc-http-host="0.0.0.0"
rpc-http-port=8545
rpc-http-cors-origins=["*"]

rpc-ws-enabled=true
rpc-ws-host="0.0.0.0"
rpc-ws-port=8546
rpc-ws-api=["WEB3","ETH","NET","EEA","ADMIN"]
rpc-ws-authentication-enabled=false

graphql-http-enabled=true
graphql-http-host="0.0.0.0"
graphql-http-port=8547
graphql-http-cors-origins=["*"]

metrics-enabled=true
metrics-host="0.0.0.0"
metrics-port=9545

The script that i am using to read events:

const Web3 = require('web3');
var web3 = new Web3('ws://localhost:8546')
const abi = [{ "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "eventValue", "type": "event" }, { "inputs": [{ "internalType": "uint256", "name": "_val", "type": "uint256" }], "name": "launchEvent", "outputs": [], "stateMutability": "nonpayable", "type": "function" }];
const contractAddress = "0xBe0B0f08A599F07699E98A9D001084e97b9a900A";

var contractsInstance = new web3.eth.Contract(abi, contractAddress);
contractsInstance.events.allEvents({
address: contractAddress,
fromBlock: 0
}, function (error, event) { console.log(event); })
.on('data', function (event) {
console.log(event);
})
.on('changed', function (event) {
})
.on('error', console.error);

When I run the script I get the following error all the time:

node ReadEvent.js
null
Error: connection not open on send()
at Object.ConnectionError (/home/rr/Documentos/git/events/node_modules/web3-core-helpers/src/errors.js:72:23)
at Object.ConnectionNotOpenError (/home/rr/Documentos/git/events/node_modules/web3-core-helpers/src/errors.js:51:21)
at /home/rr/Documentos/git/events/node_modules/web3-providers-ws/src/index.js:183:37
at Map.forEach ()
at WebsocketProvider._onClose (/home/rr/Documentos/git/events/node_modules/web3-providers-ws/src/index.js:182:27)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/rr/Documentos/git/events/node_modules/yaeti/lib/EventTarget.js:115:12)
at W3CWebSocket.onConnectFailed (/home/rr/Documentos/git/events/node_modules/websocket/lib/W3CWebSocket.js:219:14)
at WebSocketClient. (/home/rr/Documentos/git/events/node_modules/websocket/lib/W3CWebSocket.js:59:25)
at WebSocketClient.emit (events.js:315:20)
at ClientRequest.handleRequestError (/home/rr/Documentos/git/events/node_modules/websocket/lib/WebSocketClient.js:227:14)
at ClientRequest.emit (events.js:315:20)
at Socket.socketErrorListener (_http_client.js:426:9)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 1006,
reason: 'connection failed'
}
false
Error: connection not open on send()
at Object.ConnectionError (/home/rr/Documentos/git/events/node_modules/web3-core-helpers/src/errors.js:72:23)
at Object.ConnectionNotOpenError (/home/rr/Documentos/git/events/node_modules/web3-core-helpers/src/errors.js:51:21)
at /home/rr/Documentos/git/events/node_modules/web3-providers-ws/src/index.js:183:37
at Map.forEach ()
at WebsocketProvider._onClose (/home/rr/Documentos/git/events/node_modules/web3-providers-ws/src/index.js:182:27)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/rr/Documentos/git/events/node_modules/yaeti/lib/EventTarget.js:115:12)
at W3CWebSocket.onConnectFailed (/home/rr/Documentos/git/events/node_modules/websocket/lib/W3CWebSocket.js:219:14)
at WebSocketClient. (/home/rr/Documentos/git/events/node_modules/websocket/lib/W3CWebSocket.js:59:25)
at WebSocketClient.emit (events.js:315:20)
at ClientRequest.handleRequestError (/home/rr/Documentos/git/events/node_modules/websocket/lib/WebSocketClient.js:227:14)
at ClientRequest.emit (events.js:315:20)
at Socket.socketErrorListener (_http_client.js:426:9)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 1006,
reason: 'connection failed'
}

I able to recover the events in ganache but I don't know what I'm doing wrong.

¿Any idea?

Thank you

"web3": "^1.2.11"
Besu: latest version

@shemnon
Copy link
Contributor

shemnon commented Jul 20, 2020

First, what version of Besu are you using?

You are querying all events from block zero and we are timing out getting all the events.

fromBlock: 0
Change that to a more current block, or leave the option out.

Finally, what network is being connected to?

@ARR552
Copy link
Author

ARR552 commented Jul 20, 2020

Hey @shemnon
I'm using besu/v1.5.0/linux-x86_64/oracle_openjdk-java-11 (docker version)
I'm getting the same error removing fromBlock: 0.
What do you mean when you ask to which network i am connected to?

@MadelineMurray
Copy link
Contributor

@ARR552 - are you connected to a public network (eg, mainnet, rinkeby, etc) or to a private network?

@shemnon
Copy link
Contributor

shemnon commented Jul 20, 2020

Can you change the fromBlock: to a block number closer to the chainhead?

@ARR552
Copy link
Author

ARR552 commented Jul 20, 2020

@MadelineMurray I am connected to a private network. However the same code in ganache is working.
@shemnon I try with block 9000 (the chain has only 9500 blocks for now) but i get the same error.

@shemnon
Copy link
Contributor

shemnon commented Jul 20, 2020

It must be something other than too many logs. We will need to reproduce this in-house. How loaded is the chain with data? Is the contract you are calling open source?

@ARR552
Copy link
Author

ARR552 commented Jul 21, 2020

pragma solidity ^0.6.11;

contract eventContract {

event eventValue(address sender, uint amount); // Event

function launchEvent(uint _val) public {
    emit eventValue(msg.sender, _val); // Triggering event
}

}
Only this SmartContract is deployed on the besu network.
Maybe it is a configuration problem, I don't know.

@timbeiko timbeiko added bug Something isn't working P4 Low (ex: Node doesn't start up when the configuration file has unexpected "end-of-line" character) labels Jul 27, 2020
@non-fungible-nelson non-fungible-nelson added the icebox items that need more consideration, time, or can wait label May 24, 2022
@iamhsk iamhsk added the TeamChupa GH issues worked on by Chupacabara Team label Jul 14, 2022
@jflo jflo removed the TeamChupa GH issues worked on by Chupacabara Team label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working icebox items that need more consideration, time, or can wait P4 Low (ex: Node doesn't start up when the configuration file has unexpected "end-of-line" character)
Projects
None yet
Development

No branches or pull requests

7 participants