Monero Asked on August 24, 2021
I started monero-wallet-rpc on a remote server (with login and password):
./monero-wallet-rpc --rpc-bind-port 18082 --wallet-dir ./wallets_test --rpc-login test:test --testnet --daemon-host node.xmr.to
Then I try to connect to it through node.js
But I receive an error:
<html><head><title>Unauthorized Access</title></head><body><h1>401 Unauthorized</h1></body></html>
However, when I start monero-wallet-rpc on 127.0.0.1 with same login and password it works just fine:
{ id: '0', jsonrpc: '2.0', result: {} }
P.S.
When I use curl
it works fine with both (remote and local) servers:
IP=127.0.0.1
PORT=18082
METHOD="create_wallet"
PARAMS="{"filename":"test123","language": "English", "password":""}"
curl
-u ddd:ddd --digest
-X POST http://$IP:$PORT/json_rpc
-d '{"jsonrpc":"2.0","id":"0","method":"'$METHOD'","params":'"$PARAMS"'}'
-H 'Content-Type: application/json'
Nodejs request example:
const request = require("request");
request.post(
"http://127.0.0.1:18082/json_rpc",
{
forever: true,
json: {
jsonrpc: "2.0",
id: "0",
method: "create_wallet",
params: { filename: "megatest123", password: "", language: "English" }
},
auth: {
user: "test",
pass: "test",
sendImmediately: false
}
},
function(err, res, body) {
console.log(body);
}
);
What can be the reason of such weird behaviour?
Well there seems to be quite a few open issues using that particular nodejs library with digest auth. I suggest using another library. The fact it works with curl proves this is not a Monero issue.
Answered by jtgrassie on August 24, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP