I have Ethereum node running the JSON RPC server on this IP example 136.10.164.134
. Then I want to use a client to push some data. I see this library to make the client.
But I can't connect to my server. I got this error :
requests.exceptions.ConnectionError: HTTPConnectionPool(host='136.10.164.134', port=8545):
Max retries exceeded with url: / (Caused by NewConnectionError
('<requests.packages.urllib3.connection.HTTPConnection object at 0x10ecfacd0>:
Failed to establish a new connection: [Errno 61] Connection refused',))
I just put these 3 lines as it's mentioned in the documentation like this in my python script :
from eth_rpc_client import Client
client = Client(host="136.10.164.134", port="8545")
client.get_coinbase()
I think I can't connect to my server because the password itsn't defined in my script. How can I send the server password in ethereum rpc client ?
Edit
Ok So now I fixed the connection problem. I reconfigured parity with this command line :
geth --rpc --rpcaddr <ip> --rpcport <portnumber>
And set my IP to the web3 object :
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new Web3.providers.HttpProvider('http://136.10.164.134:8545'));
web3.eth.syncing
But now I have another problem. I have this error :
ValueError: No JSON object could be decoded
I'm watching the network with Charles and I can see this :
415 Unsupported Media Type
Supplied content type is not allowed. Content-Type: application/json is required
Of course the content-type sent is text/html; charset=utf-8
.
How can I change the content type with this Ethererum rpc client ?
geth --rpc --rpcaddr <ip> --rpcport <portnumber>
and change the web3 ip like this :web3.setProvider(new Web3.providers.HttpProvider('http://136.10.164.134:8545'));
instead of local host. But now I have a problem with the content type.ethereum-rpc-client
. It's no longer supported. Take a look at web3.py if you want a python option for connecting to an RPC server.