BitShares Forum
Main => General Discussion => Topic started by: jbutta2k13 on July 10, 2014, 07:43:17 pm
-
I have the rpc server started but I cannot connect using python and requests....can someone tell me why I am getting this error. I have no problems conneting python to http server..
ConnectionError: HTTPConnectionPool(host='localhost', port=18332): Max retries exceeded with url: / (Caused by <class 'socket.error'>: [Errno 10061] No connection could be made because the target machine actively refused it)
config.json rpc info
"rpc": {
"enable": true,
"rpc_user": "user",
"rpc_password": "1234",
"rpc_endpoint": "localhost:18832",
"httpd_endpoint": "localhost:8801",
"htdocs": "./htdocs"
python code snippet....
serverURL = 'http://' + rpc_user + ':' + rpc_password + '@localhost:' + str(rpcPort)
headers = {'content-type': 'application/json'}
payload = json.dumps({"method": 'get_info', "jsonrpc": "2.0"})
response = requests.get(serverURL, headers=headers, data=payload)
print(response.json()['result'])
-
Have a look at this example, good luck
https://github.com/Bitsuperlab/Bitshares_optools/blob/master/batch_enable_delegates.py (https://github.com/Bitsuperlab/Bitshares_optools/blob/master/batch_enable_delegates.py)
-
Looks like you are not querying "host:port/rpc" but just "host:port"
-
Hack and toast....Thanks alot. I wish I saw those in earlier in the git...
-
No idea whats up but when I want to use the RPC interface via python the bitshares_client gets killed because of [out of memory] .. WTF?
-
No idea whats up but when I want to use the RPC interface via python the bitshares_client gets killed because of [out of memory] .. WTF?
There are 2 rpc ports... (one that takes straight JSON and the other that is HTTP based). If you use the straight JSON and send an HTTP request it triggers a bug that behaves like you describe.
-
I see .. gonna check that
edit:
at least I am now getting a Invalid RPC Request. Thanks .. from here I can handle it my self ..
-
What am I doing wrong:
curl --data '{"method":"about"}' http://xeroc:***********@localhost:19988/rpc
Invalid RPC Request
6 key_not_found_exception: Key Not Found
Key method
{"key":"method"}
th_a variant_object.cpp:90 operator[]
-
Try:
curl --data '{"method":"about", "params": [], "json-rpc": 2.0, "id": 0}' http://xeroc:***********@localhost:19988/rpc
seems like the "json-rpc" is not required by the bitshares server (although it's more correct to have it). "id" and "params" are both required (you can set "id" to whatever you want, it's user by the server in the reply to identify the request to which it is responding).
-
Try:
curl --data '{"method":"about", "params": [], "json-rpc": 2.0, "id": 0}' http://xeroc:***********@localhost:19988/rpc
seems like the "json-rpc" is not required by the bitshares server (although it's more correct to have it). "id" and "params" are both required (you can set "id" to whatever you want, it's user by the server in the reply to identify the request to which it is responding).
Some guy told me that the RPC 1.0 not works, but RPC 2.0 work, that might be the reason.
-
Try:
curl --data '{"method":"about", "params": [], "json-rpc": 2.0, "id": 0}' http://xeroc:***********@localhost:19988/rpc
seems like the "json-rpc" is not required by the bitshares server (although it's more correct to have it). "id" and "params" are both required (you can set "id" to whatever you want, it's user by the server in the reply to identify the request to which it is responding).
Thx .. worked
-
This time I try to connect to the RPC interface using NodeJS
The code:
var request = require('request');
request.post("http://localhost:19988/rpc/", {
json: {"method":"about","params":[],"json-rpc": 2.0,"id":0} },
function (error, response, body) {
console.log(body);
}
).auth('xeroc', 'secret');
The transmitted message:
POST /rpc/ HTTP/1.1
host: localhost:19988
accept: application/json
content-type: application/json
content-length: 50
authorization: Basic authentication-hash
Connection: keep-alive
{"method":"about","params":[],"json-rpc":2,"id":0}
The result:
Unauthorized
As a reference, the curl message that result in the desired about message:
POST /rpc HTTP/1.1
Authorization: Basic authentication-hash
User-Agent: curl/7.37.0
Host: localhost:19988
Accept: */*
Content-Length: 58
Content-Type: application/x-www-form-urlencoded
{"method":"about", "params": [], "json-rpc": 2.0, "id": 0}
What am I missing?
-
You need to set RPC user and password both in the config and your client
-
Client request has the authorization line which is the http basic auth you are talking about .. the has is removed from my quotes as it would allow login .. second request works .. first dies not
-
I figured it out ... the header names are CASE-SENSITIVE!! .. wtf
//edit .. hm sth else is wrong .. using a request (telnet) from the machine where the wallet is running to localhost works ..
using the request from somewhere else connecting to that machine gives me a "Connection reset by peer" ...
however using 'curl' all works fine .. I might screw sth here ..
-
my issue really is caused by
"authentication" != "Authentication" in the header ...
-
I'm having problems with RPC on v0.8.
$ curl --user user:pass http://127.0.0.1:1776/rpc -X POST -H 'Content-Type: application/json' -d '{"method" : "blockchain_get_account", "params" : ["dev0.theoretical"], "id" : 1}'
curl: (7) Failed connect to 127.0.0.1:1776; Connection refused
Config is:
"rpc": {
"enable": true,
"enable_cache": true,
"rpc_user": "user",
"rpc_password": "pass",
"rpc_endpoint": "127.0.0.1:1775",
"httpd_endpoint": "127.0.0.1:1776",
"encrypted_rpc_endpoint": "127.0.0.1:0",
"encrypted_rpc_wif_key": "",
"htdocs": "./htdocs"
},