zhyulong
zhyulong

Reputation: 31

use docker container composer-rest-server to generate rest api appears:REQUEST_TIMEOUT

I want to use composer-rest-server to generate rest api. 1,I run composer network ping -c admin@trade-network the result is :

```The connection to the network was successfully tested: trade-network Business network version: 0.2.6-20180530153450 Composer runtime version: 0.19.8 participant: org.hyperledger.composer.system.NetworkAdmin#admin identity: org.hyperledger.composer.system.Identity#8633aef10e9d998be8bec4bb4ab535eb74e3d6832cb21286b89cadf0e95863c5

Command succeeded 2,run `docker run -e COMPOSER_CARD=admin@trade-network -e COMPOSER_NAMESPACES=never --name rest -p 3000:3000 hyperledger/composer-rest-server` while error appears: [2018-06-15 08:18:17] PM2 log: Launching in no daemon mode [2018-06-15 08:18:17] PM2 log: Starting execution sequence in -fork mode- for app name:composer-rest-server id:0 [2018-06-15 08:18:17] PM2 log: App name:composer-rest-server id:0 online WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names. WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode Discovering types from business network definition ... Exception: Error: Error trying to ping. Error: REQUEST_TIMEOUT Connection fails: Error: Error trying to ping. Error: REQUEST_TIMEOUT It will be retried for the next request. Error: Error trying to ping. Error: REQUEST_TIMEOUT at _checkRuntimeVersions.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:790:34) at at process._tickDomainCallback (internal/process/next_tick.js:228:7) [2018-06-15 08:23:21] PM2 log: App [composer-rest-server] with id [0] and pid [15], exited with code [1] via signal [SIGINT] [2018-06-15 08:23:21] PM2 log: Starting execution sequence in -fork mode- for app name:composer-rest-server id:0 [2018-06-15 08:23:21] PM2 log: App name:composer-rest-server id:0 online WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names. WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode Discovering types from business network definition ... Connection fails: Error: Error trying to ping. Error: REQUEST_TIMEOUT It will be retried for the next request. Exception: Error: Error trying to ping. Error: REQUEST_TIMEOUT Error: Error trying to ping. Error: REQUEST_TIMEOUT ``` so I want to ask why?

Upvotes: 0

Views: 352

Answers (1)

R Thatcher
R Thatcher

Reputation: 5570

This is a networking issue ... The URL values in your connection.json (part of the "Card") have localhost in them which works fine from the command line of your computer where Docker sets up Port forwarding into the containers of the Fabric. When you use the same card inside a rest container localhost loops back into the container and does not "see" the Fabric.

Step 6 of this tutorial deals with the problem by creating a special restadmin card, and modifying the addresses in the connection.json to 'find' the Fabric - Google Oauth2 Tutorial.

I assume you are already sharing a volume on the docker run command so that the Rest Container can find the folder with the cards. E.g. -v ~/.composer:/home/composer/.composer

Upvotes: 1

Related Questions