Parece que no puedo crear un proveedor web3 (http) que apunte a un nodo de paridad, ejecutándose desde un contenedor docker. Creo un repositorio que debería reproducir el problema.
Después de ejecutar, docker-compose up
se inicia la paridad, pero la aplicación falla:
Creating network "dockerweb3_net" with driver "bridge"
Attaching to qa_parity, qa_app
qa_parity | 2018-09-27 07:50:52 UTC Starting Parity-Ethereum/v2.0.6-stable-7658d22-20180921/x86_64-linux-gnu/rustc1.29.0
qa_parity | 2018-09-27 07:50:52 UTC Keys path /root/.local/share/io.parity.ethereum//keys/test
qa_parity | 2018-09-27 07:50:52 UTC DB path /root/.local/share/io.parity.ethereum//chains/test/db/ae90623718e47d66
qa_parity | 2018-09-27 07:50:52 UTC State DB configuration: fast
qa_parity | 2018-09-27 07:50:52 UTC Operating mode: active
qa_parity | 2018-09-27 07:50:52 UTC Configured for Ropsten using Ethash engine
qa_app | /app/app.js:6
qa_app | throw "Can't connect to Ethereum node: qa_parity:8545";
Ahora, si obtengo un shell para el contenedor que falla en la misma red acoplable, puedo alcanzar la paridad:
docker run --net dockerweb3_net -it dockerweb3_app /bin/bash
curl --data '{"method":"web3_clientVersion","params":[],"id":1,"jsonrpc":"2.0"}' \
-H "Content-Type: application/json" \
-X POST qa_parity:8545
> {"jsonrpc":"2.0","result":"Parity-Ethereum//v2.0.6-stable-7658d22-20180921/x86_64-linux-gnu/rustc1.29.0","id":1}
Como 8545 está expuesto, la paridad también es accesible desde el host ( http://localhost:8545
), por lo que el problema debe venir al crear el proveedor .
Parece que web3 simplemente requiere una ruta completa y no solo la dirección IP. Conectarse al contenedor y pasar la URL funciona:
env URL_PARITY="http://qa_parity:8545" node app.js
Nicolás Massart
fbielejec