【问题标题】:Error sending command to Beanstalkd from telnet从 telnet 向 Beanstalkd 发送命令时出错
【发布时间】:2020-02-14 07:45:53
【问题描述】:

当我通过 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

【问题讨论】:

标签: telnet beanstalkd


【解决方案1】:

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

- &lt;data&gt; is the job body -- a sequence of bytes of length &lt;bytes&gt; 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

【讨论】:

    猜你喜欢
    • 2013-07-07
    • 2014-01-30
    • 2015-03-05
    • 2018-01-03
    • 2013-08-22
    • 2015-02-19
    • 2013-04-09
    • 2018-12-13
    • 2017-04-13
    相关资源
    最近更新 更多