I am following the tutorial Using Google OAUTH2.0 with a REST server (https://hyperledger.github.io/composer/latest/tutorials/google_oauth2_rest). After login with success into my Google account, I get this error on the browser:
{
"error": {
"statusCode": 500,
"name": "InternalOAuthError",
"message": "Failed to obtain access token",
"oauthError": {
"errno": "ENOTFOUND",
"code": "ENOTFOUND",
"syscall": "getaddrinfo",
"hostname": "accounts.google.com",
"host": "accounts.google.com",
"port": 443
},
"stack": "InternalOAuthError: Failed to obtain access token\n at Strategy.OAuth2Strategy._createOAuthError (/home/composer/node_modules/passport-oauth2/lib/strategy.js:379:17)\n at /home/composer/node_modules/passport-oauth2/lib/strategy.js:166:45\n at /home/composer/node_modules/oauth/lib/oauth2.js:191:18\n at ClientRequest.<anonymous> (/home/composer/node_modules/oauth/lib/oauth2.js:162:5)\n at emitOne (events.js:116:13)\n at ClientRequest.emit (events.js:211:7)\n at TLSSocket.socketErrorListener (_http_client.js:387:9)\n at emitOne (events.js:116:13)\n at TLSSocket.emit (events.js:211:7)\n at emitErrorNT (internal/streams/destroy.js:66:8)\n at args.(anonymous function) (/home/composer/.npm-global/lib/node_modules/pm2/node_modules/event-loop-inspector/index.js:138:29)\n at _combinedTickCallback (internal/process/next_tick.js:139:11)\n at process._tickDomainCallback (internal/process/next_tick.js:219:9)"
}
}
I am behind a corporate proxy. So, I suspect there it is the problem but I am not sure.
Following the tutorial instructions, I edited the file Dockerfile for adding npm configuration of the proxy (ip and port with the right data):
FROM hyperledger/composer-rest-server
RUN npm config set proxy http://ip:port && npm config set https-proxy http://ip:port && \
npm install --production loopback-connector-mongodb passport-google-oauth2 request https-proxy-agent && \
npm cache clean --force && \
ln -s node_modules .node_modules
Also, and I added request and https-proxy-agent modules for implementing the workaround explaining here: Use Passport.js Behind Corporate Firewall for Facebook Strategy, but with no success.
I built the Docker image composer-rest-server like this:
docker build -t myorg/composer-rest-server --build-arg http_proxy=http://ip:port --build-arg https_proxy=http://ip:port .
When I ran the Docker container, this was the log:
[2018-09-28T10:48:18.240Z] PM2 log: Launching in no daemon mode
[2018-09-28T10:48:18.318Z] PM2 log: Starting execution sequence in -fork mode- for app name:composer-rest-server id:0
[2018-09-28T10:48:18.325Z] 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 ...
(node:15) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
Discovering the Returning Transactions..
Discovered types from business network definition
Generating schemas for all types in business network definition ...
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
And, after login to my Google account, this was the log:
Unhandled error for request GET /auth/google/callback?code=4%2FbAC3w3UnnALN4kKQD8RdjfC_wrXJeFAojIHKOANISGWYn-zvIzTeO24P96T_SaJDhVBPcbdqrmLxUyv9IajeYrg&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.me+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.profile.agerange.read+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.profile.language.read+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile: InternalOAuthError: Failed to obtain access token
at Strategy.OAuth2Strategy._createOAuthError (/home/composer/node_modules/passport-oauth2/lib/strategy.js:379:17)
at /home/composer/node_modules/passport-oauth2/lib/strategy.js:166:45
at /home/composer/node_modules/oauth/lib/oauth2.js:191:18
at ClientRequest. (/home/composer/node_modules/oauth/lib/oauth2.js:162:5)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:66:8)
at args.(anonymous function) (/home/composer/.npm-global/lib/node_modules/pm2/node_modules/event-loop-inspector/index.js:138:29)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
And this is COMPOSER_PROVIDERS variable, with the right clientID and clientSecret values:
COMPOSER_PROVIDERS='{
"google": {
"provider": "google",
"module": "passport-google-oauth2",
"clientID": "REPLACE_WITH_CLIENT_ID",
"clientSecret": "REPLACE_WITH_CLIENT_SECRET",
"authPath": "/auth/google",
"callbackURL": "/auth/google/callback",
"scope": "https://www.googleapis.com/auth/plus.login",
"successRedirect": "/",
"failureRedirect": "/"
}
Anyone could tell me where is the problem?
Thanks.
PD: Sorry for this brick!
Related
I am trying to create a serverless project. But it gives an error when giving the serverless command on the cmd. Please help me to solve this.
first I installed the serverless with 'npm install -g serverless' command. Then I gave 'serverless' command. So following error was displayed on the cmd.
C:\Geethma\myFiles\serverlessTutorial>serverless
Creating a new serverless project
? What do you want to make? AWS - Node.js - Starter
? What do you want to call this project? aws-node-project
Environment: win32, node 16.15.0, framework 3.18.2, plugin 6.2.2, SDK 4.3.2
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
RequestError: self signed certificate in certificate chain
at ClientRequest.<anonymous> (C:\Users\geethma.rathnayake\AppData\Roaming\npm\node_modules\serverless\node_modules\got\dist\source\core\index.js:962:111)
at Object.onceWrapper (node:events:642:26)
at ClientRequest.emit (node:events:539:35)
at ClientRequest.emit (node:domain:475:12)
at ClientRequest.origin.emit (C:\Users\geethma.rathnayake\AppData\Roaming\npm\node_modules\serverless\node_modules\#szmarczak\http-timer\dist\source\index.js:43:20)
at TLSSocket.socketErrorListener (node:_http_client:454:9)
at TLSSocket.emit (node:events:527:28)
at TLSSocket.emit (node:domain:475:12)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
at TLSSocket.onConnectSecure (node:_tls_wrap:1532:34)
at TLSSocket.emit (node:events:527:28)
at TLSSocket.emit (node:domain:475:12)
at TLSSocket._finishInit (node:_tls_wrap:946:8)
at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:727:12)
If you're using a machine provided by an employer, they may have installed self-signed SSL certificates in order to connect to internal systems or run fleet management software.
You can override strict checking in Node by either prepending the command with NODE_TLS_REJECT_UNAUTHORIZED=0 serverless, or permanently with npm config set strict-ssl false.
I had checked with Aaron's answer, but it didn't work for my case.
Issue on my side was with my company's VPN, as it was blocking sending/receiving the data. I went with the below steps that solved my issue.
Solution
Try disabling the VPN.
Run the command again.
Verify if it works.
Also make sure that your IAM user has necessary privileges to perform this by attaching necessary policy in the AWS's IAM User page.
node enrollAdmin.js
error: [FabricCAClientService.js]: Failed to enroll admin, error:%o message=Calling enrollment endpoint failed with error [Error: con
nect ECONNREFUSED 127.0.0.1:7054], stack=Error: Calling enrollment endpoint fail
ed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]
at ClientRequest.request.on (C:\Users\Nibir Hira\go\src\github.com\hyperledg
er\fabric-samples\fabcar\javascript\node_modules\fabric-ca-client\lib\FabricCACl
ient.js:487:12)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Failed to enroll admin user "admin": Error: Calling enrollment endpoint failed w
ith error [Error: connect ECONNREFUSED 127.0.0.1:7054]
Where should I do corrections? The file registeradmin.js is not even working
Here is a solution for Hyperledger Fabric v2.x. The problem is port no: 7054 is missing in test network.
In Linux (try if it works in virtual box), one way to solve is fresh restart from fabcar folder (not test network folder) then run again.
cd $HOME/fabric-samples/fabcar
./startFabric.sh javascript (by default it's goLang)
A fresh restart of the network will occur as "startFabric.sh" contains network up, down, chaincode installing, all in one.
Now try again:
node enrollAdmin.js
Worked for me.
Extra: Now you can run node registerUser.js and node invoke.js if you were about to use invoke.js .
Your node application cannot connect to the Fabric CA server running in the container - so either it is not running, has failed or possibly you have some firewall or other connectivity problem.
You can test connectivity by using wget or curl or a browser to hit this URL - http://localhost:7054/api/v1/cainfo and until you can hit this URL your enrollAdmin program will fail.
I don't use windows, but docker ps on Linux would tell me if the ca container was running, and docker logs ca.example.com would give me the log of the ca container (assuming you are running the fabcar sample on the basic sample network.)
I had the exact same problem. This worked for me:
Open VirtualBox Manager and select the “default” VM
Click “Settings”, “Network”, “Advanced”, “Port Forwarding”.
Create a new rule by clicking the “+” sign on the right and entering the following: Name -> “ca”, Host Port -> 7054, Guest Port -> 7054.
You can leave the Host IP and Guest IP unspecified.
Source:
https://developer.ibm.com/opentech/2017/11/29/running-hyperledger-fabric-windows-revised/
I was trying to deploy hyperledger fabric on multiple hosts using this code and used the balance transfer chaincode using node-SDK. While I tried to enroll the user, I got the following error:
[2019-01-10 18:12:20.635] [ERROR] Helper -
[FabricCAClientService.js]: Failed to enroll admin, error:Error:
Calling enrollment endpoint failed with error [Error: write EPROTO
140678895621952:error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown
protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827:
]
at ClientRequest.request.on (/home/muzzam/Downloads/hlf-docker-swarm/hlf-app/node_modules/fabric-ca-client/lib/FabricCAClient.js:492:12)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at onwriteError (_stream_writable.js:417:12)
at onwrite (_stream_writable.js:439:5)
at _destroy (internal/streams/destroy.js:39:7)
at TLSSocket.Socket._destroy (net.js:568:3)
can anyone give me an idea of what could be going wrong? If you need any of my configuration file, i can provide that
I was able to find my error.
I was not setting the TLS enabled parameter in docker containing CA service.
You need to set the following properties in yaml file containg the CA services:
environment:
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=<location to certificate file>
- FABRIC_CA_SERVER_TLS_KEYFILE=<location to key file>
I have done enketo-express installtion while launching enkto it shows below error. I'm using this command to launch enketo "npm start"
AbortError: Ready check failed: Redis connection lost and command aborted. It might have been processed.
at RedisClient.flush_and_error (enketo-express/node_modules/redis/index.js:362:23)
at RedisClient.connection_gone (enketo-express/node_modules/redis/index.js:664:14)
at Socket. (enketo-express/node_modules/redis/index.js:293:14)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Worker 7873 sadly passed away. It will be reincarnated.
Note: Following this doc step no: 7
check netstat -ntlp
which port is using 8005
or in some case something running on port 6380
"cache": {
"host": "127.0.0.1",
"port": "6379", # change port from 6380
"password": null
}
Also Different Node version too causes similar problems. Use node version as described in readme
https://github.com/kobotoolbox/enketo-express/issues/528
I am having this problem while connecting the elasticsearch connections.
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({ host: 'localhost:9200',
log: 'trace'});
Elasticsearch ERROR: 2016-07-19T19:09:26Z
Error: Request error, retrying -- connect ECONNREFUSED 127.0.0.1:9200
at Log.error (/root/git_build/FirstMoveChess/node_modules/elasticsearch/src/lib/log.js:225:56)
at checkRespForFailure (/root/git_build/FirstMoveChess/node_modules/elasticsearch/src/lib/transport.js:195:18)
at HttpConnector. (/root/git_build/FirstMoveChess/node_modules/elasticsearch/src/lib/connectors/http.js:154:7)
at ClientRequest.bound (/root/git_build/FirstMoveChess/node_modules/lodash-node/modern/internals/baseBind.js:56:17)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:308:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1272:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Elasticsearch TRACE: 2016-07-19T19:09:27Z
-> HEAD http://localhost:9200/
I understand this question is quite old but I wanted to share how you can solve this problem.
If you are locally using elasticsearch
First thing you must do is running elasticsearch on your machine.
Error: Request error, retrying -- connect ECONNREFUSED 127.0.0.1:9200
Because above message indicates that you're not running elasticsearch locally.
So, visit the link and follow the insturction.
Docker environment
It gets much trickier here.
First, follow the instruction here.
And in case you're using node.js elasticsearch client, you have to specify elasticsearch host as 172.24.0.1.
If you use container_name or private IP of container in docker-compose.yml, it won't work.
In case of Docker Container Environment after changing from http://localhost:9200 to http://ipaddress:9200 in docker-compose.yml
please change the following live in docker-compose.yml that is related to CORS
Change this
** http.cors.allow-origin=/https?://localhost(:[0-9]+)?/ **
into this
*- http.cors.allow-origin= **