WietseWind / docker-rippled

Run XRP Ledger (rippled) node in a Docker container
https://hub.docker.com/r/xrpllabsofficial/xrpld
MIT License
60 stars 34 forks source link

I want to make an RPC call with Postman. please help me~! #21

Closed junghyun0783 closed 1 year ago

junghyun0783 commented 1 year ago

I want to make an RPC call with Postman. However, the RPC call does not work. I'm using a docker image called (xrpllabsofficial/xrpld:latest). I'll explain a scenario I've been working on.

  1. Create a container docker run -itd --name xrp_testvalidator -e TESTVAR=123123 --network medalla -p 40048:80 -p 40049:51235 -p 40050:5005 -p 40051:51234 -p 40052:6006 -p 40053:50051 -p 40054 :443 -v D:\docker\container\testnet\xrp_validator\config/:/config/ -v D:\docker\container\testnet\xrp_validator\db/:/var/lib/rippled/db/ xrpllabsofficial/xrpld: latest

  2. Rippled.cfg and validators.txt used previously provided files, and are located in "D:\docker\container\testnet\xrp_validator\config".

  3. RPC call url : https://localhost:40048~40054 (post) content: { "method": "ledger", "params": [ { "ledger_index": "validated", "accounts": false, "full": false, "transactions": false, "expand": false, "owner_funds": false } ] } Error content: Error: Client network socket disconnected before secure TLS connection was established

please. I want to run a Ripple node. But it doesn't work as well as intended. Please help me make RPC calls possible.

junghyun0783 commented 1 year ago

Oh and docker exec rippled server_info When the command is executed, the output is as follows.

Args:

[server_info]

Env Args:

[]

Env: HOSTNAME=187eb0e84edc TESTVAR=123123 PWD=/ HOME=/root SHLVL=2 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin _=/usr/bin/printenv

Existing rippled config at host /config/, using. Existing validator config at host /config/, using. Loading: "/etc/opt/ripple/rippled.cfg" 2023-Aug-01 08:48:33.809994815 UTC HTTPClient:NFO Connecting to 127.0.0.1:5005

{ "result" : { "info" : { "build_version" : "1.11.0", "closed_ledger" : { "age" : 3, "base_fee_xrp" : 1e-05, "hash" : "05310AE4909B482AAD9CF513A5E713EBD8AE34277E2683B2C032865A376A6F8C", "reserve_base_xrp" : 10, "reserve_inc_xrp" : 2, "seq" : 2 }, "complete_ledgers" : "empty", "hostid" : "187eb0e84edc", "io_latency_ms" : 1, "jq_trans_overflow" : "0", "last_close" : { "converge_time_s" : 0, "proposers" : 0 }, "load" : { "job_types" : [ { "in_progress" : 1, "job_type" : "clientRPC" } ], "threads" : 6 }, "load_factor" : 1, "node_size" : "small", "peer_disconnects" : "0", "peer_disconnects_resources" : "0", "peers" : 0, "pubkey_node" : "n9Mr6HsZZz8NC7aJ3Br6XVuzRda73N68oC2kXxV4sfK9wAkYJ4R6", "pubkey_validator" : "none", "published_ledger" : "none", "server_state" : "connected", "server_state_duration_us" : "834439", "state_accounting" : { "connected" : { "duration_us" : "834439", "transitions" : "1" }, "disconnected" : { "duration_us" : "161041", "transitions" : "1" }, "full" : { "duration_us" : "0", "transitions" : "0" }, "syncing" : { "duration_us" : "0", "transitions" : "0" }, "tracking" : { "duration_us" : "0", "transitions" : "0" } }, "time" : "2023-Aug-01 08:48:33.810583 UTC", "uptime" : 5, "validation_quorum" : 4294967295, "validator_list" : { "count" : 1, "expiration" : "2024-Apr-28 00:00:00.000000000 UTC", "status" : "active" } }, "status" : "success" } }

WietseWind commented 1 year ago

Looks like the solution is very simple:

Port 40048 would be the right one to call, as the -p command maps that to :80 where the webserver is running (providing you have the port 80 access stanza in the config enabled).

However, I also see: --network medalla

My guess is that that network configured in docker isn't bridged to localhost, meaning you'd have to call on the IP assigned to the machine on that network.

junghyun0783 commented 1 year ago

@WietseWind Thank you for your kind reply. Then in the config file

[port_ws_public] port=80 ip = 0.0.0.0 protocol = ws

If you set it like this, it should be called without any problems, right? And --network medalla was removed. Still can't call... I used the rippled.cfg file as it was provided.

junghyun0783 commented 1 year ago

@WietseWind I also checked that the port is open with tcping.

C:\Users\D-YNLEE>tcping 192.168.2.70 40048 Probing 192.168.2.70:40048/tcp - Port is open - time=2.533ms Probing 192.168.2.70:40048/tcp - Port is open - time=0.759ms Probing 192.168.2.70:40048/tcp - Port is open - time=0.711ms Probing 192.168.2.70:40048/tcp - Port is open - time=1.143ms

There seems to be nothing wrong with the port... Why can't POSTMAN make RPC calls? RPC calls are In the rippled.cfg file [port_rpc_admin_local] port=5005 ip = 127.0.0.1 admin=127.0.0.1 protocol = http Isn't it being called with this stanza? I knew that...

WietseWind commented 1 year ago

The aforementioned port, port 80, which you have mapped to 40048, is not the RPC port, it is the WebSocket port. Meaning you can connect with a bidirectional websocket client to it, not HTTP POST with postman.

The port 5005 is also not available with the config you quote, as you can see it's only bound to 127.0.0.1: the IP local to the container. As it is an admin port.

You have several options:

  1. Expose the RPC admin port by running it on 0.0.0.0 (all IPs) and map a public port to the container local 5005 port.
  2. Add config to run a non-admin RPC port, and map to that

Please note that your admin port mapping is specified by you on another TCP port outside of the container: -p 40050:5005 means that you connect locally to 40050 to reach 5005 inside the container.

Run it like this (rippled.cfg) to make it accessible:

ip = 0.0.0.0
admin=127.0.0.1

Meaning: publicly accessible, but only admin if called by localhost.