title: XMPP reply from GAE to Google+ doesn't work
body: <p>I've noticed errors in my Google App Engine Log while parsing messages. The stack trace was unhelpful to diagnose the problem, so I wrote a small message dumper inspired by Google's implementation of <a href="http://www.google.com/codesearch#Qx8E-7HUBTk/trunk/java/src/main/com/google/appengine/api/xmpp/InboundMessageParser.java&amp;type=cs" rel="nofollow">InboundMessageParser</a>.</p>
  
  <pre><code>public class ChatRequestParser extends HttpRequestParser {
  
      public static Map&lt;String, String&gt; parseMessage(HttpServletRequest request)
      throws IOException {
          try {
              Map&lt;String, String&gt; message = new HashMap&lt;String, String&gt;();
              MimeMultipart multipart = parseMultipartRequest(request);
              int parts = multipart.getCount();
              for (int i = 0; i &lt; parts; i++) {
                  BodyPart part = multipart.getBodyPart(i);
                  String fieldName = getFieldName(part);
                  String fieldValue = getTextContent(part);
                  message.put(fieldName, fieldValue);
              }
              return message;
          } catch (MessagingException ex) {
              throw new IOException("Could not parse incoming request.", ex);
          }
      }
  
  }
  </code></pre>
  
  <p>I found out that Google+ sends two messages for each message, only one of which contains a body (Gmail Talk client sends only one message).</p>
  
  <p>Here is the first message, without a body:</p>
  
  <pre><code>{to=xxx@appspot.com, stanza=&lt;message to="xxx@appspot.com" type="chat"
  from="yyy@gmail.com/TalkGadgetD9F45A83" xmlns="jabber:client"&gt;
  &lt;cha:composing xmlns:cha="http://jabber.org/protocol/chatstates"/&gt;
  &lt;nos:x value="disabled" xmlns:nos="google:nosave"/&gt;
  &lt;arc:record otr="false" xmlns:arc="http://jabber.org/protocol/archive"/&gt;
  &lt;/message&gt;, from=yyy@gmail.com/TalkGadgetD9F45A83}
  </code></pre>
  
  <p>And the second one is (my payload is many asterisks, mails changed):</p>
  
  <pre><code>{to=xxx@appspot.com, body=**********************************, 
  stanza=&lt;message to="xxx@appspot.com" type="chat" 
  id="7279D79D0.17809585028724073_:sl" from="yyy@gmail.com/TalkGadgetD9F45A83"
  xmlns="jabber:client"&gt;&lt;body&gt;**********************************&lt;/body&gt;
  &lt;cha:active xmlns:cha="http://jabber.org/protocol/chatstates"/&gt;
  &lt;nos:x value="disabled" xmlns:nos="google:nosave"/&gt;&lt;arc:record otr="false"
  xmlns:arc="http://jabber.org/protocol/archive"/&gt;&lt;/message&gt;,
  from=yyy@gmail.com/TalkGadgetD9F45A83}
  </code></pre>
  
  <p>Since the first message doesn't have a body calling parseMessage() on XMPPService throws exception. Has anyone noticed this problem? </p>
  
  <p>Now I am catching the IllegalArgumentException and throwing away meaningless messages, but the real problem is, that <strong>the reply to the valid message doesn't arrive back to Google+</strong> client, while works perfectly with Gmail and also with my Jabber client on Linux.</p>
  
  <p>I've filed <a href="http://code.google.com/p/googleappengine/issues/detail?id=6467" rel="nofollow">issue 6467</a>.</p>