I'm trying to get the BTSX client to talk to a node.js app using RPC. The client starts the RPC server fine:
$ ./bitshares_client --server --httpport 9989
Loading blockchain from "/home/eightbit/.BitSharesX/chain"
Loading config "/home/eightbit/.BitSharesX/config.json"
Starting JSON RPC server on port 50022 (localhost only)
Starting HTTP JSON RPC server on port 9989 (localhost only)
But when I try to run my node.js server, I get:
Client: TODO Status Code: 400
Which refers to:
4xx Client Error
The 4xx class of status code is intended for cases in which the client seems to have errored. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents should display any included entity to the user.
400 Bad Request
The request cannot be fulfilled due to bad syntax.
Here is the RPC section of my config.json:
"rpc": {
"enable": true,
"rpc_user": "test",
"rpc_password": "test",
"rpc_endpoint": "127.0.0.1:0",
"httpd_endpoint": "127.0.0.1:0",
"htdocs": "/"
},
and here is the code I'm using in node:
DELBID.rpc = require('node-json-rpc');
DELBID.rpc.options = {
// int port of rpc server, default 5080 for http or 5433 for https
port: 9989,
// string domain name or ip of rpc server, default '127.0.0.1'
host: '127.0.0.1',
//username
login: "test",
//password
hash: "test"
// string with default path, default '/'
path: '/',
// boolean false to turn rpc checks off, default true
strict: true,
};
// Create a server object with options
DELBID.rpc.client = new DELBID.rpc.Client(DELBID.rpc.options);
//run blockchain_get_config in the wallet and print the results to the console
DELBID.rpc.client.call({"jsonrpc": "2.0", "method": "blockchain_get_config", "params": []}, function(err, res) {
if (err) { console.log(err); } else {
console.log(res);
}
});
I'm not exactly sure how the node.js 'path' and the bitshares config 'htdocs' elements function, so I feel the issue might stem from them. Also, perhaps the rpc method names are different from the hooks in the interactive client? If they are, are they documented anywhere?