从 telnet 向 Beanstalkd 发送命令时出错

Error sending command to Beanstalkd from telnet

当我通过 telnet 发送以下序列时,我得到 EXPECTED_CRLF:

$ telnet localhost 11300
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
put 0 0 1 4 
68 6f 6c 61
EXPECTED_CRLF
UNKNOWN_COMMAND

我想,当我在 telnet 中按 "Enter" 时,它会发送一个 "CR LF" (https://www.freesoft.org/CIE/RFC/1123/31.htm)

Beanstalkd 协议在这里:https://github.com/beanstalkd/beanstalkd/blob/master/doc/protocol.txt

我试过像@Alister Bulman 说的那样切换 crlf,但没有成功:

$ telnet
telnet> toggle crlf
Will send carriage returns as telnet <CR><LF>.
telnet> open localhost 11300
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
put 0 0 1 4
68 6f 6c 61
EXPECTED_CRLF
UNKNOWN_COMMAND

这里的问题是:您可以发送文本而不用字节编码。对于文本 "hola" 是正确的 4 字节,但对于“68 6f 6c 61”必须是“11”字节长度。 我误解了协议,因为它被描述为 "a sequence of bytes" for <data>。事实上,TCP 传输是一个字节流!

- <data> is the job body -- a sequence of bytes of length <bytes> from the previous line.

所以正确的命令是:

$ telnet
telnet> open localhost 11300
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
put 0 0 1 4
hola
INSERTED 1
put 0 0 1 11
68 6f 6c 61
INSERTED 2