0

hope all are good ? I have a pb with my FULL NODE i can't connect it with my nodeJs files I can use my node if file's url is localhost:8546, i'm able to run my script from my server only but i want use my servr with my PC

From my server folder :

root@x:/home/x/bsc/build/bin

For Geth i run command :

./geth console --config ./config.toml --datadir ./node --cache 8000 --maxpeers 500000000 -- 
rpc.allow-unprotected-txs --txlookuplimit 0 --syncmode full --ws --ws.addr *0.0.0.0**
 ws.port 8546 --wsorigins '*'  --wsapi web3,shh,txpool,debug 

Geth is synced

My server have port open for : ssh 22 / port 8546 tcp and udp

I can connect with PUTTY

My files is:

const Web3 = require('web3');
const wsProvider = new Web3.providers.WebsocketProvider("ws://MyiPNodeAddress:8546")
const web3 = new Web3(wsProvider);


web3.eth.getBlockNumber().then((result) => {
  console.log("Latest Ethereum Block is ",result);
});

and return this :

Error: connection not open on send()

I'm using my mobile phone network connected to my Windows and i'm trying to connect to my geth linux server node then. I can't connect with my node can someone explain me please why ?

Sincerely Mike

3
  • do a netstat -pant as root and check if the port is open at the interface you are using to connect. most likely you are listening on loopback address (interface lo)
    – Nulik
    Jan 26, 2023 at 21:25
  • also there is firewall on linux by default
    – Nulik
    Jan 26, 2023 at 21:27
  • i answer you dd
    – forexmp45
    Jan 26, 2023 at 22:07

2 Answers 2

0

I am not sure if it will make difference, but make some slight adjusts in the Geth call command:

./geth console --config ./config.toml --datadir ./node --cache 8000 --maxpeers 500000000 --rpc.allow-unprotected-txs --txlookuplimit 0 --syncmode full --ws --ws.addr **0.0.0.0** --ws.port 8546 --ws.origins '*'  --ws.api web3,shh,txpool,debug

Also, you can install geth in your Windows, if you want, and try to connect with your server to test if it is open to connections:

geth attach ws://MyiPNodeAddress:8546

Finally ws is not secure, consider to connect to your server through ssh tunnel with the command and alteration in code:

ssh -N -L 8546:localhost:8546 <user>@MyiPNodeAddress

const wsProvider = new Web3.providers.WebsocketProvider("ws://localhost:8546")
3
  • I think i made a mistake if i run script in my server all work good, but i want run script from my .js files
    – forexmp45
    Jan 26, 2023 at 20:26
  • When do with ssh local when i call : web3.eth.getBlockNumber return : web3.eth.getBlockNumber() But i have the pending i put await and don't work
    – forexmp45
    Jan 27, 2023 at 17:14
  • pending response, looks like there is no connection
    – Rafael
    Jan 27, 2023 at 17:31
0

I think i made a mistake if i run script in my server all work good, but i want run script from my .js files from my Visual Studio Code and actually if do

const wsProvider = new Web3.providers.WebsocketProvider("ws://MyiPNodeAddress:8546")

it didn't work but if i run my .js directly from my server the scripts have :

const wsProvider = new Web3.providers.WebsocketProvider("ws://localhost:8546")

and it always work

I want run my script with my windows not my server i know this is better to run it with my server but its only to collecting some information not to run finnaly without ssh tunel, i just want to put my ip and work ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.