iurimatias / EtherSim

EtherSim is an Ethereum RPC simulator for testing and development purposes
MIT License
59 stars 21 forks source link

Unsupported media type #15

Open heikoheiko opened 8 years ago

heikoheiko commented 8 years ago

Hi, when trying to access via http i get "Unsupported media type" as a return value. running with ethersim

from pyethapp import rpc_client
c = rpc_client.JSONRPCClient(8101)
c.blocknumber()

sent:
{
  "jsonrpc": "2.0", 
  "method": "eth_blockNumber", 
  "id": 6
}
received:
Unsupported media type

this works when using geth or pyethapp.

I tried with web3.py as well.

agatsoh commented 8 years ago

While testing with web3.py ((https://github.com/pipermerriam/web3.py )) we get this error

(envflask) krishna@Krishna:~$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from web3 import Web3, RPCProvider, IPCProvider
>>> web3rpc = Web3(RPCProvider(host="localhost", port="8101"))
>>> web3rpc.eth.coinbase
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/krishna/Envs/envflask/local/lib/python2.7/site-packages/web3/eth.py", line 62, in coinbase
    return self.request_manager.request_blocking("eth_coinbase", [])
  File "/home/krishna/Envs/envflask/local/lib/python2.7/site-packages/web3/providers/manager.py", line 22, in request_blocking
    response = json.loads(force_text(response_raw))
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
pipermerriam commented 8 years ago

This was an issue with web3.py not sending a content-type header which was fixed with https://github.com/pipermerriam/web3.py/pull/67 and is available as 1.8.0 from pypi or within the releases section of the repository.

heikoheiko commented 8 years ago

needs to be fixed in pyethapp too https://github.com/ethereum/pyethapp/issues/164