简体   繁体   中英

Error sending command to Beanstalkd from telnet

Whenn I send the following sequence via telnet I get 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

I thought, when I press "Enter" inside telnet, it will be send an "CR LF" ( https://www.freesoft.org/CIE/RFC/1123/31.htm )

Beanstalkd Protocol here: https://github.com/beanstalkd/beanstalkd/blob/master/doc/protocol.txt

I tried toggling crlf like @Alister Bulman said, but it didn't work:

$ 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

The issue here was: you can send a text without to encode it in bytes. For the text "hola" is right 4 Bytes, but for "68 6f 6c 61" had to be "11" bytes length. I misunderstood the protocol, since it is described as "a sequence of bytes" for <data> . Indeed the TCP delivery is a stream of bytes!

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

So the correct commands are:

$ 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM