FuelLabs/fuel-js

`Error: socket hang` when connecting to `geth`

Closed this issue · 13 comments

Summary

I'm experiencing what might best be described as a UX issue when running fuel against a local geth.

There appears to be issues connecting to geth, resulting in a time-out, no helpful graceful error message, and a stack trace.

Observed behaviour

I run ./fuel --network="mainnet" --rpc="http://localhost:8545" then after some moments, I see this:

{ Error: invalid response - 0
    at exports.XMLHttpRequest.request.onreadystatechange (/snapshot/client/node_modules/ethers/utils/web.js:84:29)
    at exports.XMLHttpRequest.dispatchEvent (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at exports.XMLHttpRequest.handleError (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:532:5)
    at ClientRequest.errorHandler (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:459:14)
    at ClientRequest.emit (events.js:198:13)
    at Socket.socketOnEnd (_http_client.js:435:9)
    at Socket.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  statusCode: 0,
  responseText:
 'Error: socket hang up\n    at createHangUpError (_http_client.js:332:15)\n    at Socket.socketOnEnd (_http_client.js:435:23)\n    at Socket.emit (events.js:203:15)\n    at endReadableNT (_stream_readable.js:1145:12)\n    at process._tickCallback (internal/process/next_tick.js:63:19)' }
attempting exit

I am running geth with the following settings (with moz-extension parameters anonymised):

geth --http -http.corsdomain moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --graphql --graphql.corsdomain moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Expected behaviour

I expect that the issue is caused by a configuration of geth which is too closed, and not configured to allow fuel to connect.

If this is the case, I expect to see:

  • the stdout report a time-out from the RPC endpoint
  • the fuel node to attempt to retry geth
  • the fuel node to provide a helpful hint to what might be required to reconfigure geth (desirable)

If this is not the case, I at least expect to see fuel handle this gracefully, and report something more meaningful.

Environment

image

Incidentally, this works fine when connecting to an Infura mainnet endpoint instead of localhost geth :)

@chrishobcroft agreed, we can handle this error more gracefully. Looking into it now.

@chrishobcroft were you able to get the node connected at all? Even after multiple attempts / reconfigurations?

I'm able to reproduce the error as

✔ Please enter a Fuel wallet encryption passphrase … ********
fuel-2021-01-04 7:39:01 PM : Wallet/operator address used: 0x5e0633ab719dfD8DD36154dd52f9632828689693
fuel-2021-01-04 7:39:01 PM : DB: default local db selected.
{ Error: invalid response - 0
    at exports.XMLHttpRequest.request.onreadystatechange (/snapshot/client/node_modules/ethers/utils/web.js:84:29)
    at exports.XMLHttpRequest.dispatchEvent (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at exports.XMLHttpRequest.handleError (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:532:5)
    at ClientRequest.errorHandler (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:459:14)
    at ClientRequest.emit (events.js:198:13)
    at Socket.socketOnEnd (_http_client.js:435:9)
    at Socket.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  statusCode: 0,
  responseText:
   'Error: socket hang up\n    at createHangUpError (_http_client.js:332:15)\n    at Socket.socketOnEnd (_http_client.js:435:23)\n    at Socket.emit (events.js:203:15)\n    at endReadableNT (_stream_readable.js:1145:12)\n    at process._tickCallback (internal/process/next_tick.js:63:19)' }
attempting exit

using only geth --http.

@SilentCicero

@chrishobcroft were you able to get the node connected at all? Even after multiple attempts / reconfigurations?

I managed to get it running against an infura endpoint, but I have no clue what to start reconfiguring in my geth node settings to allow this to work.

@SilentCicero

I have a Mac environment, so I’m spinning up a simulated Linux environment

Are you envisaging fuel to be run primarily on a Mac?

@chrishobcroft a patch is on the way in our next release: #12

@adlerjohn review when ready.

I run it with geth and besides the other issues, I get contract not deployed. This geth node has been active since a couple of weeks, not sure if it is that. Seems to be working with Infura

New Beta binaries are up, with patch:
https://github.com/FuelLabs/fuel-js/releases/tag/v1.0.1-beta

I've also included building from source instructions, recommended geth settings and the intended purpose of the Node.

Thanks for trying to run our node everyone.