IBM-Blockchain-Archive / ibm-blockchain-issues

Having issues with the IBM Blockchain Bluemix service? Let us know!
13 stars 12 forks source link

First connection via node.js hfc always fails #98

Closed jonathandeclan closed 7 years ago

jonathandeclan commented 7 years ago

On the starter developer plan on Bluemix.

First call (both invoke or query) /connection via node.js hfc client application always fails with an error like below:

[SDK] error on query: {"error":{"code":14,"metadata":{"_internal_repr":{}}},"msg":"Error: {\"created\":\"@1489041318.283220044\",\"description\":\"Secure read failed\",\"file\":\"../src/core/lib/security/transport/secure_endpoint.c\",\"file_line\":157,\"grpc_status\":14,\"referenced_errors\":[{\"created\":\"@1489041318.283203825\",\"description\":\"OS Error\",\"errno\":104,\"file\":\"../src/core/lib/iomgr/tcp_posix.c\",\"file_line\":229,\"os_error\":\"Connection reset by peer\",\"syscall\":\"recvmsg\"}]}"}. Query request: {"chaincodeID":"5b938859f6c1bb14ca16fe02d033c2eacb7a2c337d307b2d137798eaebe49bf1","fcn":"get_bookings_by_user_id","args":["user001"]}. User ID: WebAppAdmin, registered: false, enrolled: true.

the subsequent calls using the exact some invoke or query will return correct responses.

dhyey20 commented 7 years ago

The problem here is that the load balancer cuts off the connections after sometime of inactivity. As grpc is a streaming protocol, it requires the connection to be active to do any communication. So the first time you try to query/invoke grpc connection(subchannel i guess) will not be active and it takes sometime to create a new connection, after that all the subsequent calls will use the same grpc-channel to communicate with the peer.

So, either you put some retries on the first call, or make sure that you have the connection running by having a keep-alive kind of call every interval.

masterDev1985 commented 7 years ago

@dhyey20 is correct.

jonathan-yk-tan commented 7 years ago

@masterDev1985 @dhyey20 what is the current timeout before the load balancer cuts off the connection? This is so we can create a script or manually do a keep-alive kind of call as @dhyey20 has proposed.