I have configured below pre-requisites for JWT based authentication to Salesforce sandbox.
- ConnectedApp
- server.key
- Client Id
I am trying to authenticate Salesforce sandbox from client's Jenkins using below command which is part of Jenkins pipeline.
sfdx auth:jwt:grant --instanceurl https://test.salesforce.com --clientid ${Client_Id} --jwtkeyfile server.key --username ${Username} --json
However, I am getting read ECONNRESET error. Below is the complete json response
{ "status": 1, "name": "JwtGrant", "message": "We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: Error authenticating with JWT config due to: request to https://test.salesforce.com//services/oauth2/token failed, reason: read ECONNRESET\nrequest to https://login.salesforce.com/services/oauth2/token failed, reason: read ECONNRESET\nrequest to https://test.salesforce.com//services/oauth2/token failed, reason: read ECONNRESET", "exitCode": 1, "context": "Grant", "stack": "JwtGrant: We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: Error authenticating with JWT config due to: request to https://test.salesforce.com//services/oauth2/token failed, reason: read ECONNRESET\nrequest to https://login.salesforce.com/services/oauth2/token failed, reason: read ECONNRESET\nrequest to https://test.salesforce.com//services/oauth2/token failed, reason: read ECONNRESET\n at Messages.createError (/opt/apps/jenkins/node-v16.15.0-linux-x64/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/messages.js:446:16)\n at Grant.run (/opt/apps/jenkins/node-v16.15.0-linux-x64/lib/node_modules/sfdx-cli/node_modules/@salesforce/plugin-auth/lib/commands/auth/jwt/grant.js:35:28)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at async Grant._run (/opt/apps/jenkins/node-v16.15.0-linux-x64/lib/node_modules/sfdx-cli/node_modules/@salesforce/command/lib/sfdxCommand.js:89:40)\n at async Config.runCommand (/opt/apps/jenkins/node-v16.15.0-linux-x64/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/config/config.js:272:25)\n at async run (/opt/apps/jenkins/node-v16.15.0-linux-x64/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/main.js:76:5)", "warnings": [], "commandName": "Grant" }
With the same set of configuration, I am able to authenticate the same Salesforce sandbox from my local system. To check whether there are any port connectivity issue from client's Jenkins I tried to make Telnet connection to test.salesforce.com and login.salesforce.com on port 443 & telnet was able to communicate to target.
telnet test.salesforce.com 443 Trying 13.110.250.33... Connected to test.salesforce.com. Escape character is '^]'. Connection closed by foreign host.
telnet login.salesforce.com 443 Trying 13.110.251.32... Connected to login.salesforce.com. Escape character is '^]'. Connection closed by foreign host.
I still suspect that it is underlying network issue. Have anyone faced this type of issue ? Any pointers and help is highly appreciated.
Thanks!
instanceurl
that is MyDomain-ed. ECONNRESET is usually a proxy issue. telnet might confirm that the port is open but whatever component is intercepting your request might be protocol-specific: it will stop HTTPS but not plain TCP traffic. Usually corporate proxies that rewrite SSL traffic have this property. Usecurl
orwget
to confirm this hypothesis.