title: How come the redis-benchmark command is not following the redis protocol?
body: <p>I was reading in directly from a tcp connection after running the <code>redis-benchmark</code> command and as far as I can tell, <code>redis-benchmark</code> is NOT following the redis protocol.</p>
  
  <p>The <a href="http://redis.io/topics/protocol" rel="nofollow">redis protocol</a> is as stated in its website:</p>
  
  <blockquote>
    <p>The way RESP is used in Redis as a request-response protocol is the
    following:</p>
    
    <ul>
    <li>Clients send commands to a Redis server as a RESP Array of Bulk    Strings. </li>
    <li>The server replies with one of the RESP types according to    the command implementation.</li>
    </ul>
  </blockquote>
  
  <p>Meaning that a correct client implementation must always send <strong>RESP arrays of bulk strings.</strong></p>
  
  <p>If that is true, then, anything that does not start with a * is considered a syntax error (since its not an RESP array).</p>
  
  <p>Thus, if one were to send a ping command to a redis-server, then it must be sent as a resp array of length 1 with 1 bulk string containing the word ping. For example:</p>
  
  <blockquote>
    <p>"*1\r\n$4\r\nPING\r\n"</p>
  </blockquote>
  
  <p>However, whenever I listen directly to the redis-benchmark command and read its tcp connection I get instead:</p>
  
  <blockquote>
    <p>"PING\r\n"</p>
  </blockquote>
  
  <p>which does <strong>not</strong> follow the redis protocol. Is that a bug or is there something implied in the redis protocol that makes pings special? As far as I could tell I couldn't find anything that said that pings were special, nor that length 1 commands were special. Does someone know whats going on?</p>
  
  <p>To see reproduce these results yourself you can copy <a href="http://play.golang.org/p/smEp254J5n" rel="nofollow">my code</a> to inspect it directly:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "log"
      "net"
  )
  
  func main() {
      RedisBenchmark()
  }
  
  func RedisBenchmark() {
      url := "127.0.0.1:6379"
      fmt.Println("listen: ", url)
      ln, err := net.Listen("tcp", url) //announces on local network
      if err != nil {
          log.Fatal(err)
      }
      for {
          conn, err := ln.Accept() //waits and returns the next connection to the listener
          if err != nil {
              log.Fatal(err)
          }
  
          tcpConn := conn.(*net.TCPConn)
          go HandleConnection(tcpConn)
      }
  }
  
  func HandleConnection(tcpConn *net.TCPConn) {
      b := make([]byte, 256) //TODO how much should I read at a time?
      n, err := tcpConn.Read(b)
      if err != nil {
          fmt.Println("n: ", n)
          log.Fatal(err)
      }
      fmt.Printf("+++++&gt; raw input string(b): %q\n", string(b))
      msg := string(b[:n])
      fmt.Printf("+++++&gt; raw input msg: %q\n", msg)
  }
  </code></pre>
  
  <p>and run it using go with:</p>
  
  <p><code>go run main.go</code></p>
  
  <p>followed on a different terminal (or tmux pane):</p>
  
  <p><code>redis-benchmark</code></p>
  
  <p>for all the test or if you only want to run ping with 1 client:</p>
  
  <p>redis-benchmark -c 1 -t ping -n 1</p>
  
  <p>you can see the details of how I am running it with the flags at: <a href="http://redis.io/topics/benchmarks" rel="nofollow">http://redis.io/topics/benchmarks</a></p>