XRPL-Labs / xrpld-hooks

ISC License
94 stars 28 forks source link

How to access docker image ws://localhost:6005 from external DAPP #29

Closed Goochie closed 2 years ago

Goochie commented 2 years ago

Summary

I have the container running fine and are able to edit the examples.

Next step in my dApp POC is to connect the dApp running locally to the testnet in the container

Issue

When creating a new RippleAPI ......

const api = new RippleAPI({server: 'ws://localhost:6005'});

.... i get the following issue.

NotConnectedError: connect ECONNREFUSED 127.0.0.1:6005

I appreciate this is not a feature request or issue your side :) but i have exhausted stack overflow solutions - ie replacing localhost with image name etc

So hopefully i am just missing some configuration my side - FYI i am windows 10

Thanks in advance ...

WietseWind commented 2 years ago

Hey,

Two things:

  1. To expose a port from inside a docker container to your host, add -p {outside}:{inside} to the command to run the container. E.g. docker run -d -p 6005:6005 --name xrpld-hooks xrpllabsofficial/xrpld-hooks-testnet
  2. Now you can call that locally. If you want to call it from a remote location, you'll have to expose your local port to the public internet. You can do that with helpers like ngrok, localtunnel and other services.
Goochie commented 2 years ago

@WietseWind Thank you so much and id like to add some great work you guys are doing over there ...