steemit / steem

The blockchain for Smart Media Tokens (SMTs) and decentralized applications.
https://steem.com
Other
1.95k stars 793 forks source link

Can't connect to wallet RPC #2602

Open alenn-m opened 6 years ago

alenn-m commented 6 years ago

It's probably a stupid question but I can't fix this issue. I'm running a Steem node which is built with docker, everything is ok there, I can connect to RPC with curl and commands are executing properly. I need some commands from the wallet but they are not available when I list all commands. After reading the documentation I figured out I need to start the cli_wallet and connect it to the steemd, so I tried with this command: docker exec -it steemd-exchange /usr/local/steemd-default/bin/cli_wallet --server-rpc-endpoint=ws://127.0.0.1:8091 -w /var/steemwallet/wallet.json and this is the error:

Logging RPC to file: logs/rpc/rpc.log
2511124ms th_a       main.cpp:154                  main                 ] wdata.ws_server: ws://127.0.0.1:8091 
0 exception: unspecified
Underlying Transport Error
    {"message":"Underlying Transport Error"}
    asio  websocket.cpp:444 operator()

    {"uri":"ws://127.0.0.1:8091"}
    th_a  websocket.cpp:673 connect

What am I doing wrong? How to use wallet commands with RPC so I can programmatically control my account?

mvandeberg commented 6 years ago

Are you connecting to the correct endpoint?

https://github.com/steemit/steem/blob/master/contrib/steemd.run#L103-L130

ws://127.0.0.1:8091 is only the steemd endpoint if you specified running steemd behind nginx.

alenn-m commented 6 years ago

Thanks @mvandeberg now the cli_wallet can connect to the steemd, but now I can't connect to the cli_wallet, I tried connecting from the same server and from my computer but it refuses connection. This is the command I used:

docker exec -it steemd-exchange /usr/local/steemd-default/bin/cli_wallet --server-rpc-endpoint=ws://0.0.0.0:8090 -w /var/steemwallet/wallet.json -H 127.0.0.1:8093 --rpc-http-allowip 213.91.104.54 127.0.0.1 0.0.0.0

And this is the output:

 2411371ms th_a       main.cpp:101                  main                 ] allowed_ips: ["213.91.104.54","127.0.0.1","0.0.0.0"] 
Logging RPC to file: logs/rpc/rpc.log
2411382ms th_a       main.cpp:154                  main                 ] wdata.ws_server: ws://0.0.0.0:8090 
2411391ms th_a       main.cpp:159                  main                 ] wdata.ws_user:  wdata.ws_password:  
2422847ms th_a       websocket_api.cpp:88          on_message           ] message: {"id":1,"result":true} 
2422852ms th_a       websocket_api.cpp:88          on_message           ] message: {"id":2,"result":0} 
2422852ms th_a       websocket_api.cpp:88          on_message           ] message: {"id":3,"result":3} 
2422854ms th_a       main.cpp:227                  main                 ] Listening for incoming HTTP RPC requests on 127.0.0.1:8093

As you can see it's listening to 127.0.0.1:8093 and I allowed my IP address, but when I try to execute any command with curl, my connection is rejected.

mvandeberg commented 6 years ago

If you are attempting to connect from the host machine you will need to map the endpoint for the Docker container when you launch the container.

alenn-m commented 6 years ago

Yes, I was attempting to connect from the host machine. I exposed the port 8093 in docker. How do I map the endpoint?