ngx-distributed-shm icon indicating copy to clipboard operation
ngx-distributed-shm copied to clipboard

telnet error

Open alexist opened this issue 1 year ago • 1 comments

Hi,

When testing SET command with telnet, i get an malformed_request

SET KEY 0 1
1
LEN 1
1
DONE
ERROR malformed_request

In unit test, we don't have the malformed_request, because "\r\n" is not send

getWriter().write("SET region:key 1 10\r\n");
getWriter().write("1234567890");
getWriter().flush();

Maybe there is a way to send the command without carriage return in telnet ?

Otherwhise, this issue can be fixed in two ways

  1. Setting an expectedMode to FrameMode.END
 else if (expectedMode == FrameMode.DATA) {
       final String result = currentCommand.executeDataPart(buffer.toString(PROTOCOL_ENCODING));
       socket.write(result, PROTOCOL_ENCODING);
       expectedMode = FrameMode.END;
       parser.delimitedMode(PROTOCOL_DELIMITER);
  }
  else {
        expectedMode = FrameMode.COMMAND;
   }

but this will make a breaking change

  1. Handling empty command in ShmProtocolHandler.handle : if (expectedMode == FrameMode.COMMAND && !buffer.toString(PROTOCOL_ENCODING).isEmpty()) { } but not sure allowing empty command is a good idea

alexist avatar Nov 21 '23 10:11 alexist