-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Can't interact with geth over http or ws from node.js express app #3600
Comments
The error messages indicate the connection isn't getting established. How are you instantiating Web3? There is a simple Web3 Express example here that might be worth looking at. It uses Web3 0.2.x and would need to be updated for Web3 1.x. But it might help you identify some small issue in your code that's making it fail.
This suggests it's not a Web3 issue per se, but a problem with the way you're using Express. |
Thanks for the example. Unfortunately, it doesn't really help. My app uses Typescript and ES6 classes. This could be a scoping issue on my part, but I'm not seeing it right now, and I've done similar things in the past. I would think that if I'm following the same patterns, and that was the issue, mongodb and web3 wouldn't work, but mongodb does work. This is how I'm instantiating web3
i've been trying ws and http, but only one at a time. Even if I instantiate Web3 and try to interact with geth all in the same scope/function, i still get the result above. |
ok. dumb mistake. the ip address of my server with the geth node changed (without restarting the server, which is strange). 🤦🏼♂️ |
Expected behavior
Can interact with node over http or ws from node.js express app
Actual behavior
over http:
over ws:
Steps to reproduce the behavior
Logs
I'm running a geth client with the
--debug
synced to ropsten and there are no related messages on the console.Environment
node v12.16.3, web3 v1.2.9 (also tried 1.2.8), macOS 10.15 and Ubuntu 18
i've tried
web3.eth.getAccounts()
and something like:if i'm not running the express api in front of the web3 connection, everything works as desired. this only happens when the web3 connection is initiated from the express app.
The text was updated successfully, but these errors were encountered: