工作生活

nodejs:帐号密码链接elasticsearch

2019-07-04  本文已影响0人  四宝日记

const { Client } = require('@elastic/elasticsearch')

const client = new Client({ node: 'http://[usrname]:[passwd]@[hostname]:8080' })

若passwd中包含特殊符号,需要用“站长工具”,进行一次url编码。

重要的事情说3次,http,http,http

千万别用https,如果你想这样的话:

ConnectionError: write EPROTO 140226063316768:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332: at onResponse ....../node_modules/@elastic/elasticsearch/lib/Transport.js:220:13) at ClientRequest.request.on.err ....../node_modules/@elastic/elasticsearch/lib/Connection.js:114:9) at ClientRequest.emit (events.js:198:13) at TLSSocket.socketErrorListener (_http_client.js:392:9) at TLSSocket.emit (events.js:198:13) at errorOrDestroy (internal/streams/destroy.js:107:12) at onwriteError (_stream_writable.js:436:5) at onwrite (_stream_writable.js:461:5) at _destroy (internal/streams/destroy.js:49:7) at TLSSocket.Socket._destroy (net.js:613:3)

上一篇 下一篇

猜你喜欢

热点阅读