web3.py: Timeout error when I tried to send transaction

I don’t understanda why, but since few days, I can’t send transaction. When I do web3.eth.sendTransaction(transaction) I’ve this error timeout: timed out.

the transaction looks like this : transaction = {'from': user2, 'to':user1, 'data': web3.toHex("test")} And user1 and user2are defined . Accounts are unlocked and have gas…

Have you got any idea?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

For future readers who encounter this problem, one way to resolve it is by changing this:

HTTPProvider('http://137.xxx.xxxx.xxxx:8545')

To this:

HTTPProvider('http://137.xxx.xxxx.xxxx:8545',request_kwargs={'timeout':60})

As the default timeout is 10 (seconds).

@shanefontaine: It involves inter-process communication, so technically speaking, any time-duration is possible, especially when the communication is over HTTP. Evidently, they added the timeout configuration parameter, so there’s gotta be good reason for that, wouldn’t you agree? Practically, the reason I wrote this is because I ran into a sporadic timeout scenario, which I was able to resolve by increasing the timeout. By the way, it’s not about sending a transaction, it’s about receiving a response to it (on the client side, where you configure the timeout).

I have the same problem here with geth as the node. I have an HTTPConnectionPool() read timeout in listener.get() > eth_getFilterChanges() > ....

Any guidance on how to deal with these read timeouts if web3.py doesn’t?

I thought about wrapping listener.get() with a try{} catch{} but if listener.get() updates the last block it requested events from then we might miss some events.

@pipermerriam , Yes I can access the RPC server because when I do or exemple

from web3 import Web3, HTTPProvider
web3 = Web3(HTTPProvider('http://137.xxx.xxxx.xxxx:8545'))
web3.eth.coinbase
web3.eth.blockNumber

I’ve a response : 0x.. or 321815

But when I want to do sendTransaction command I always have this error :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/web3/utils/string.py", line 83, in inner
    return force_obj_to_text(fn(*args, **kwargs))
  File "/usr/local/lib/python2.7/dist-packages/web3/eth.py", line 252, in sendTransaction
    [formatters.input_transaction_formatter(self, formatted_transaction)],
  File "/usr/local/lib/python2.7/dist-packages/web3/providers/manager.py", line 42, in request_blocking
    response_raw = self.provider.make_request(method, params)
  File "/usr/local/lib/python2.7/dist-packages/web3/providers/rpc.py", line 47, in make_request
    **self.get_request_kwargs()
  File "/usr/local/lib/python2.7/dist-packages/web3/utils/compat/compat_requests.py", line 6, in make_post_request
    response = requests.post(endpoint_uri, data=data, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 499, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='137.xxx.xxx.xxx', port=8545): Read timed out. (read timeout=10)

And with web.js I’ve the same result :

Error: Invalid JSON RPC response: "Provided Host header is not whitelisted.\n"
    at Object.InvalidResponse (/Users/vigizen/node_modules/web3/lib/web3/errors.js:35:16)
    at HttpProvider.send (/Users/vigizen/node_modules/web3/lib/web3/httpprovider.js:91:22)
    at RequestManager.send (/Users/vigizen/node_modules/web3/lib/web3/requestmanager.js:58:32)
    at Eth.get [as blockNumber] (/Users/vigizen/node_modules/web3/lib/web3/property.js:107:62)
    at repl:1:9
    at realRunInThisContextScript (vm.js:22:35)
    at sigintHandlersWrap (vm.js:98:12)
    at ContextifyScript.Script.runInThisContext (vm.js:24:12)
    at REPLServer.defaultEval (repl.js:346:29)
    at bound (domain.js:280:14)