From within a docker container I'm unable to call the JSONRPCWallet.
See the traceback:
>>> from monero.wallet import Wallet
>>> from monero.backends.jsonrpc import JSONRPCWallet
>>> w = Wallet(JSONRPCWallet(host="host.docker.internal",port=28088))
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 158, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 80, in create_connection
raise err
File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 70, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 597, in urlopen
httplib_response = self._make_request(conn, method, url,
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.8/http/client.py", line 1256, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1302, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1251, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1011, in _send_output
self.send(msg)
File "/usr/local/lib/python3.8/http/client.py", line 951, in send
self.connect()
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 181, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 167, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f3cbe2449a0>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 637, in urlopen
retries = retries.increment(method, url, error=e, _pool=self,
File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='host.docker.internal', port=28088): Max retries exceeded with url: /json_rpc (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3cbe2449a0>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/monero/wallet.py", line 43, in __init__
self.refresh()
File "/usr/local/lib/python3.8/site-packages/monero/wallet.py", line 54, in refresh
for _acc in self._backend.accounts():
File "/usr/local/lib/python3.8/site-packages/monero/backends/jsonrpc/wallet.py", line 78, in accounts
_accounts = self.raw_request("get_accounts")
File "/usr/local/lib/python3.8/site-packages/monero/backends/jsonrpc/wallet.py", line 391, in raw_request
rsp = self.session.post(
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 581, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='host.docker.internal', port=28088): Max retries exceeded with url: /json_rpc (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3cbe2449a0>: Failed to establish a new connection: [Errno 111] Connection refused'))
My setup & Steps to reproduce
I'm using doodba to connect from the odoo container to my localhost machine where the walletrpc is running.
I've modified the dockers container network to allow external connections by setting. internal: false.
I've read this article How to connect to the Docker host from inside a Docker container .
Using the methods outlied in the article, I've setup the groovy Helloworld example.
From the doodba folder I can enter the container with the command:
docker-compose -f devel.yaml run --rm odoo bash
Then I can successfully curl http://host.docker.internal:8080.
Response: Hello world container. You are able to reach the Docker host!
So it's verified the docker container can access a service running on the host machine.
Onto the walletrpc. On the local machine it is running. The commands from the docs can be run successfully.
Now, Lets try to acces the walletrpc from within the docker container.
From within the doodba folder where the yaml files are. run:
docker-compose -f devel.yaml run --rm odoo bash to enter the container.
Then,
curl http://host.docker.internal:28088
result: curl: (7) Failed to connect to host.docker.internal port 28088: Connection refused
Then enter python environment, python3 I've put in the commands from the top of this post. Resulting in the error.
Expected behavior
From an docker container the walletrpc should be approachable.
Maybe, I'm doing something wrong. Help is needed.
Goals is to further develop monerodoo
If you can't connect with curl it definitely means the network configuration is incorrect. Perhaps you have a firewall blocking port 28088? Anyway, it's far out of the scope of monero-python development.
From within a docker container I'm unable to call the JSONRPCWallet. See the traceback:
My setup & Steps to reproduce
I'm using doodba to connect from the odoo container to my localhost machine where the walletrpc is running. I've modified the dockers container network to allow external connections by setting.
internal: false
. I've read this article How to connect to the Docker host from inside a Docker container . Using the methods outlied in the article, I've setup the groovy Helloworld example. From the doodba folder I can enter the container with the command:docker-compose -f devel.yaml run --rm odoo bash
Then I can successfullycurl http://host.docker.internal:8080
. Response:Hello world container. You are able to reach the Docker host!
So it's verified the docker container can access a service running on the host machine.Onto the walletrpc. On the local machine it is running. The commands from the docs can be run successfully.
Now, Lets try to acces the walletrpc from within the docker container. From within the doodba folder where the yaml files are. run:
docker-compose -f devel.yaml run --rm odoo bash
to enter the container. Then,curl http://host.docker.internal:28088
result:curl: (7) Failed to connect to host.docker.internal port 28088: Connection refused
Then enter python environment,
python3
I've put in the commands from the top of this post. Resulting in the error.Expected behavior From an docker container the walletrpc should be approachable. Maybe, I'm doing something wrong. Help is needed. Goals is to further develop monerodoo