Search code examples
azurehyperledger-composer

cannot take data on Hyperledger Composer-rest-server after a few minutes, timeout


I have created an Hyperledger Composer-rest-server from azure Ubuntu server. I tried to connect it with amazon server, I have successfully connected them. The only problem is that I cannot install composer-rest-server from amazon side nor install business card from amazon side. So I opened up composer-rest-server from azure side. But after a while, the server will not giving anymore data. It will give error time out that looks like

Generated schemas for all types in business network definition
Adding schemas for all types to Loopback ...
Added schemas for all types to Loopback
Web server listening at: http://localhost:3000
Browse your REST API at http://localhost:3000/explorer
Unhandled error for request GET /api/queries/selectCommodities: Error: REQUEST_TIMEOUT
    at Timeout._onTimeout (/home/ptech_root/.nvm/versions/node/v8.14.0/lib/node_modules/composer-rest-server/node_modules/fabric-client/lib/Peer.js:94:20)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
Unhandled error for request GET /api/queries/selectCommodities: Error: REQUEST_TIMEOUT
    at Timeout._onTimeout (/home/ptech_root/.nvm/versions/node/v8.14.0/lib/node_modules/composer-rest-server/node_modules/fabric-client/lib/Peer.js:94:20)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)

after I restart the composer-rest-server it will become normal again. But this happens randomly and occurs like every 5 minutes. What cause this? what can I do about this? I am really new on Hyperledger, I appreciate any help.


Solution

  • There have been some changes to "grpc" one of the underlying protocols used by Fabric, and this can cause timeout problems.

    You can change the default grpc options for the Composer REST Server connection to the peers by modifying the connection.json of the card you are using to start the REST server.

    For each peer in the connection.json add the following settings:

    "grpcOptions": {
                "grpc.keepalive_time_ms": 120000,
                "grpc.http2.min_time_between_pings_ms": 120000,
                "grpc.keepalive_timeout_ms": 20000,
                "grpc.http2.max_pings_without_data": 0,
                "grpc.keepalive_permit_without_calls": 1
            }
    

    The most important is "grpc.http2.max_pings_without_data": 0 so you could just try that to begin with.