[英]XMPP reply from GAE to Google+ doesn't work
I've noticed errors in my Google App Engine Log while parsing messages. 我在解析邮件时发现了我的Google App Engine日志中的错误。 The stack trace was unhelpful to diagnose the problem, so I wrote a small message dumper inspired by Google's implementation of InboundMessageParser .
堆栈跟踪无法诊断问题,因此我编写了一个受Google的InboundMessageParser实现启发的小型消息转储器 。
public class ChatRequestParser extends HttpRequestParser {
public static Map<String, String> parseMessage(HttpServletRequest request)
throws IOException {
try {
Map<String, String> message = new HashMap<String, String>();
MimeMultipart multipart = parseMultipartRequest(request);
int parts = multipart.getCount();
for (int i = 0; i < 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);
}
}
}
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). 我发现Google+会为每封邮件发送两封邮件,其中只有一封邮件包含正文(Gmail Talk客户端只发送一封邮件)。
Here is the first message, without a body: 这是第一条消息,没有正文:
{to=xxx@appspot.com, stanza=<message to="xxx@appspot.com" type="chat"
from="yyy@gmail.com/TalkGadgetD9F45A83" xmlns="jabber:client">
<cha:composing xmlns:cha="http://jabber.org/protocol/chatstates"/>
<nos:x value="disabled" xmlns:nos="google:nosave"/>
<arc:record otr="false" xmlns:arc="http://jabber.org/protocol/archive"/>
</message>, from=yyy@gmail.com/TalkGadgetD9F45A83}
And the second one is (my payload is many asterisks, mails changed): 第二个是(我的有效载荷是许多星号,邮件已更改):
{to=xxx@appspot.com, body=**********************************,
stanza=<message to="xxx@appspot.com" type="chat"
id="7279D79D0.17809585028724073_:sl" from="yyy@gmail.com/TalkGadgetD9F45A83"
xmlns="jabber:client"><body>**********************************</body>
<cha:active xmlns:cha="http://jabber.org/protocol/chatstates"/>
<nos:x value="disabled" xmlns:nos="google:nosave"/><arc:record otr="false"
xmlns:arc="http://jabber.org/protocol/archive"/></message>,
from=yyy@gmail.com/TalkGadgetD9F45A83}
Since the first message doesn't have a body calling parseMessage() on XMPPService throws exception. 由于第一条消息没有在XMPPService上调用parseMessage()的主体抛出异常。 Has anyone noticed this problem?
有人注意到这个问题吗?
Now I am catching the IllegalArgumentException and throwing away meaningless messages, but the real problem is, that the reply to the valid message doesn't arrive back to Google+ client, while works perfectly with Gmail and also with my Jabber client on Linux. 现在我正在捕捉IllegalArgumentException并抛弃无意义的消息,但真正的问题是, 对有效消息的回复不会返回到Google+客户端,同时与Gmail以及Linux上的Jabber客户端完美配合。
I've filed issue 6467 . 我已经提交了第6467期 。
I can reproduce the crash when no body is set and parseMessage is called, and I'm fixing it. 我没有设置正文并调用parseMessage时可以重现崩溃,我正在修复它。 Thanks for finding it!
谢谢你找到它!
However, I can't repro the "send reply doesn't work" bug. 但是,我无法重复“发送回复不起作用”的错误。 I have code like this:
我有这样的代码:
XMPPService xmpp = XMPPServiceFactory.getXMPPService();
Message message = xmpp.parseMessage(req);
Message reply = new MessageBuilder().withFromJid(message.getRecipientJids()[0])
.withRecipientJids(message.getFromJid())
.withBody("Back at you!")
.build();
xmpp.sendMessage(reply);
And I receive the reply both in Google+ and in Gmail. 我在Google+和Gmail中都收到了回复。 What are you doing differently?
你有什么不同的做法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.