title: Sending Stomp CONNECT Frame to ApolloMQ using Scala
body: <p>I am currently trying to send a CONNECT Stomp frame to an ApolloMQ broker using Scala.  I am doing the following:</p>
  
  <pre><code>val socketChannel: SocketChannel = SocketChannel.open
  val socketAddress: SocketAddress = new InetSocketAddress("localhost", 61613)
  val frame = "CONNECT\naccept-version:1.0,1.1,1.2\nhost:localhost\n" +
              "login:username\npasscode:password\n\n\0".toCharArray
  val byteArray = frame.map { c =&gt; c.asInstanceOf[Byte] }
  val bb = ByteBuffer.allocate(128)
  bb.put(byteArray)
  </code></pre>
  
  <p>If I then try to connect and write</p>
  
  <pre><code>socketChannel.connect(socketAddress)
  socketChannel.write(bb)
  </code></pre>
  
  <p>It seems to write, but nothing is returned and the connection is disconnected right away.  If I rewind the <code>ByteBuffer</code> first</p>
  
  <pre><code>bb.rewind
  socketChannel.connect(socketAddress)
  socketChannel.write(bb)
  </code></pre>
  
  <p>it looks like the connection is hitting Apollo, but the following is thrown</p>
  
  <pre><code>java.net.ProtocolException: The maximum command length was exceeded
  </code></pre>
  
  <p>I have searched around, but am unable to find any information as to why this seems to be happening.</p>