微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Redis ERR协议错误:太大的内联请求从服务器读取错误:对等连接重置

如何解决Redis ERR协议错误:太大的内联请求从服务器读取错误:对等连接重置

我正在使用微服务和jrch jar通过setInputStream(data)将附加数据附加到“ redis-cli --pipe”;

ShellExecuter.java

        /*
         * Open a new session,with your username,host and port Set the
         * password and call connect. session.connect() opens a new
         * connection to remote SSH server. Once the connection is
         * established,you can initiate a new channel. this channel is
         * needed to connect to remotely execution program
         */jsch = new JSch();
        session = jsch.getSession(CommonConstants.CACHE_SERVER_USERNAME,CommonConstants.CACHE_SERVER_IP,port);
        session.setConfig("StrictHostKeyChecking","no");
        session.setPassword(CommonConstants.CACHE_SERVER_PASSWORD);
        session.connect();
        
        // create the excution channel over the session
        channelExec = (ChannelExec) session.openChannel(CommonConstants.EXEC_TYPE);

        // Gets an InputStream for this channel. All data arriving in as
        // messages from the remote side can be read from this stream.
        in = channelExec.getInputStream();
        
        // Set the command that you want to execute
        // In our case its the remote shell script
        initialFile = new File(path);
        targetStream = new FileInputStream(initialFile);
        channelExec.setInputStream(targetStream);
        channelExec.setCommand(RedisConstants.REdis_CLI_PIPE);
        channelExec.setErrStream(System.err);

        // Execute the command
        channelExec.connect();

        // Read the output from the input stream we set above
        reader = new BufferedReader(new InputStreamReader(in));
        String line;

        // Read each line from the buffered reader and add it to result list
        // You can also simple print the result here
        LOG.info(logId + MessageConstants.RESPONSE_FROM_REdis + MessageConstants.START);
        while ((line = reader.readLine()) != null) {
            LOG.info(logId + CommonConstants.DOUBLE_COLON + line);
            result.add(line);
        }
        LOG.info(logId + MessageConstants.RESPONSE_FROM_REdis + MessageConstants.END);
        
        // retrieve the exit status of the remote command corresponding to
        // this channel
        int exitStatus = channelExec.getExitStatus();
        finalResult = checkExitStatus(channelExec,exitStatus,logId);
        
        // Safely disconnect channel and disconnect session. If not done
        // then it may cause resource leak
        channelExec.disconnect();
        session.disconnect();

-执行此代码后,从Redis服务器获取错误

All data transferred. Waiting for the last reply...
ERR Protocol error: too big inline request 
Error reading from the server: Connection reset by peer

Data.txt

HMSET email:cache email:variable:EN '{"data":[{"id":1,"variableName":"Channel Shop Name","variabledisplay":"${ChannelShopName}}]}.....'

-但是在上面的一行中,HMSET值很大,因此在有大量数据的最后一个命令上会得到上述错误,否则可以正常工作。

-data.txt文件中的一半数据正在添加到Redis服务器中,但是包含大量数据的命令将引发此错误

-还尝试过将命令转换为RESP(Redis协议)格式

*4
$5
HMSET
$17
application:cache
$7
DESC_EN
$12006
{"data":[{"id":1,"name":"Dashboard","imagePath":"../assets/icons/sidebar/dashboard.svg","routerLink":"user/dashboard","htmlId":"dashboard","submenus":[]}]}

但是相同错误来自redis服务器:

All data transferred. Waiting for the last reply...
    ERR Protocol error: too big inline request 
    Error reading from the server: Connection reset by peer

请提出解决方案.....

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。