iquidus / explorer

An open source block explorer
BSD 3-Clause "New" or "Revised" License
749 stars 1.33k forks source link

"No auth mechanism defined" error after upgrading to 1.6.2+ #334

Open LightBurdenOfficial opened 4 years ago

LightBurdenOfficial commented 4 years ago
Error:  { Error: no auth mechanism defined
    at Auth.onRequest (/home/spero/explorer/node_modules/request/lib/auth.js:132:32)
    at Request.auth (/home/spero/explorer/node_modules/request/request.js:1347:14)
    at Request.init (/home/spero/explorer/node_modules/request/request.js:378:10)
    at new Request (/home/spero/explorer/node_modules/request/request.js:127:8)
    at request (/home/spero/explorer/node_modules/request/index.js:53:10)
    at /home/spero/explorer/node_modules/request/index.js:61:12
    at Object.apply (/home/spero/explorer/node_modules/@uphold/request-logger/src/index.js:27:19)
    at Function.post (/home/spero/explorer/node_modules/request/index.js:100:12)
    at Function.tryCatcher (/home/spero/explorer/node_modules/bluebird/js/release/util.js:16:23)
    at Function.ret [as postAsync] (eval at makeNodePromisifiedEval (/home/spero/explorer/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:14:23)
    at _bluebird.default.try (/home/spero/explorer/node_modules/bitcoin-core/dist/src/index.js:182:27)
    at tryCatcher (/home/spero/explorer/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/home/spero/explorer/node_modules/bluebird/js/release/method.js:39:29)
    at Client.command (/home/spero/explorer/node_modules/bitcoin-core/dist/src/index.js:181:33)
    at rpcCommand (/home/spero/explorer/lib/explorer.js:23:10)
    at Object.get_difficulty (/home/spero/explorer/lib/explorer.js:141:7)
    at /home/spero/explorer/routes/index.js:287:7
    at Layer.handle [as handle_request] (/home/spero/explorer/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/spero/explorer/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/spero/explorer/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/spero/explorer/node_modules/express/lib/router/layer.js:95:5)
    at /home/spero/explorer/node_modules/express/lib/router/index.js:281:22
  cause: Error: no auth mechanism defined
    at Auth.onRequest (/home/spero/explorer/node_modules/request/lib/auth.js:132:32)
    at Request.auth (/home/spero/explorer/node_modules/request/request.js:1347:14)
    at Request.init (/home/spero/explorer/node_modules/request/request.js:378:10)
    at new Request (/home/spero/explorer/node_modules/request/request.js:127:8)
    at request (/home/spero/explorer/node_modules/request/index.js:53:10)
    at /home/spero/explorer/node_modules/request/index.js:61:12
    at Object.apply (/home/spero/explorer/node_modules/@uphold/request-logger/src/index.js:27:19)
    at Function.post (/home/spero/explorer/node_modules/request/index.js:100:12)
    at Function.tryCatcher (/home/spero/explorer/node_modules/bluebird/js/release/util.js:16:23)
    at Function.ret [as postAsync] (eval at makeNodePromisifiedEval (/home/spero/explorer/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:14:23)
    at _bluebird.default.try (/home/spero/explorer/node_modules/bitcoin-core/dist/src/index.js:182:27)
    at tryCatcher (/home/spero/explorer/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/home/spero/explorer/node_modules/bluebird/js/release/method.js:39:29)
    at Client.command (/home/spero/explorer/node_modules/bitcoin-core/dist/src/index.js:181:33)
    at rpcCommand (/home/spero/explorer/lib/explorer.js:23:10)
    at Object.get_difficulty (/home/spero/explorer/lib/explorer.js:141:7)
    at /home/spero/explorer/routes/index.js:287:7
    at Layer.handle [as handle_request] (/home/spero/explorer/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/spero/explorer/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/spero/explorer/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/spero/explorer/node_modules/express/lib/router/layer.js:95:5)
    at /home/spero/explorer/node_modules/express/lib/router/index.js:281:22,
  isOperational: true }
undefined:1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
^

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at obfuscateResponse (/home/spero/explorer/node_modules/bitcoin-core/dist/src/logging/request-obfuscator.js:60:23)
    at obfuscate (/home/spero/explorer/node_modules/bitcoin-core/dist/src/logging/request-obfuscator.js:142:3)
    at /home/spero/explorer/node_modules/bitcoin-core/dist/src/logging/request-logger.js:24:36
    at Request.<anonymous> (/home/spero/explorer/node_modules/@uphold/request-logger/src/index.js:33:9)
    at emitTwo (events.js:131:20)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/home/spero/explorer/node_modules/request/request.js:1161:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/home/spero/explorer/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickCallback (internal/process/next_tick.js:181:9)
Cluster restarting...
Ubuntu 16.04

nodejs -v
v8.17.0

npm -v
6.13.4
TheHolyRoger commented 4 years ago

You have invalid authentication details for the RPC.

@uaktags we should probably handle this new error to report what the problem is - I'll take a look into it

uaktags commented 4 years ago

Guessing he is upgrading from an older version, his user/pass is probably not updated to username/password.

LightBurdenOfficial commented 4 years ago

Guessing he is upgrading from an older version, his user/pass is probably not updated to username/password.

That was exactly my friend! I made the update in my source and it worked!

uaktags commented 4 years ago

@TheHolyRoger quick and dirty would be:

const Client = require('bitcoin-core');
if(settings.wallet.password || settings.wallet.username){
}else{
  settings.wallet.password = settings.wallet.pass;
  settings.wallet.username = settings.wallet.user;
}
const client = new Client(settings.wallet);

in explorer.js it's not a error handling measure, but it's a starting point. Perhaps instead, error handling should look into the ./bin/instance to check that everything is updated for the new versions (so if any settings.json things are changed/updates needed and they're not found, we can warn/error out before launching numerous workers for the instance.) Within there, during npm start, we can test RPC functionality, check settings.json for good configurations/upgrades needed, etc and stop/continue as per.

But regardless, I think his settings.json is from 1.6.1, @DigitalCoin1 please confirm and double check your settings.wallet.password and settings.wallet.username (it use to be called settings.wallet.pass and settings.wallet.user)

uaktags commented 4 years ago

Perfect, thanks @DigitalCoin1 for the update.

Reopening the issue and will rename it for the fact we should have error-handling for this required upgrade (it will likely cause issues for others). DigitalCoin, you can mute this issue if you'd like!

LightBurdenOfficial commented 4 years ago

Thanks!

sundanny26 commented 3 years ago

When I change from user/pass to username/password I get this error

{ Error: Invalid params, response status code: 401
    at IncomingMessage.<anonymous> (/app/node_modules/bitcoin/lib/jsonrpc.js:79:17)
    at emitNone (events.js:111:20)
    at IncomingMessage.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) code: -32602 }
GET /api/getblockcount 200 144.729 ms - 39
uaktags commented 3 years ago

@sundanny26 create a new issue next time so that you can provide your own settings. I've created #475 for you in the meantime. Please show a screenshot/output of your settings.json file as it's telling us "invalid params", so something is getting sent over incorrectly.