Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: 解决办法

问题:今天测试测流程,发现项目报下面这个错误

Redis exception; nested exception is io.lettuce.core.RedisException: io.lettuce.core.RedisConnectionException: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

 错误原因:由于redis的保护模式开启了,并且没有绑定ip地址,没有密码认证

解决:
 

找到redis的配置文件 redis.conf并编辑

vim redis.conf

1)修改 protected-mode  yes 改为:protected-mode no

2)如果本地可以,部署到服务器上不行,记得把 bind 127.0.0.1 注释。

3)设置密码访问模式,在redis.conf中加入一行密码设置 

  require 你的密码(这里有个空格)

注:记得项目重启,项目重启,项目重启!!!!(就是这个坑了我好长时间)

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
As an AI language model, I do not have personal experience with using Noble, but I can provide you with some information on how to use it. Noble is a Node.js library for interacting with Bluetooth Low Energy (BLE) devices. It provides a high-level API for connecting to and communicating with BLE devices. Here are the basic steps to use Noble: 1. Install Noble: You can install Noble using the npm package manager by running the following command: npm install noble 2. Scan for devices: Use Noble's startScanning() method to scan for nearby BLE devices. You can also filter the results by specifying the device's service UUID or MAC address. 3. Connect to a device: Once you have found a device, use Noble's connect() method to establish a connection. 4. Discover services and characteristics: Use Noble's discoverServices() and discoverCharacteristics() methods to discover the available services and characteristics of the connected device. 5. Read and write data: Once you have discovered a characteristic, you can read or write data to it using Noble's read() and write() methods. 6. Disconnect: Use Noble's disconnect() method to close the connection to the device. Here is an example code snippet that demonstrates how to use Noble: ```javascript const noble = require('noble'); noble.on('stateChange', function(state) { if (state === 'poweredOn') { noble.startScanning(); } else { noble.stopScanning(); } }); noble.on('discover', function(peripheral) { console.log('Found device with local name: ' + peripheral.advertisement.localName); console.log('Device ID: ' + peripheral.id); console.log('Device address: ' + peripheral.address); peripheral.connect(function(error) { console.log('Connected to device'); peripheral.discoverServices([], function(error, services) { services.forEach(function(service) { console.log('Found service: ' + service.uuid); service.discoverCharacteristics([], function(error, characteristics) { characteristics.forEach(function(characteristic) { console.log('Found characteristic: ' + characteristic.uuid); characteristic.read(function(error, data) { console.log('Characteristic value: ' + data.toString('hex')); }); }); }); }); }); }); }); ``` This code snippet scans for nearby BLE devices, connects to a device, discovers the available services and characteristics, and reads the value of each characteristic.
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值