Python xmpppy客户端不发送消息给appengine xmpp客户端 [英] Python xmpppy client not sending message to appengine xmpp client
问题描述
嘿伙计们,
在向应用引擎的xmpp客户端发送消息时,我似乎无法使用xmpppy客户端。
我没有收到任何错误。消息只是没有到达那里。
从应用引擎的客户端发送消息到sl4a客户端。
向google talk客户端发送和从sl4a客户端发送的消息也同样适用。
任何帮助将不胜感激。
以下是python代码
import xmpp
导入时间
_SERVER ='talk.google.com',5223
commandByXMPP()
def commandByXMPP():
全局xmppUsername
xmppUsername ='garrowsbot@gmail.com'
全球xmppPassword
xmppPassword ='obscured'
全球xmppClient
全球运营商
运营商=cellbotmote@appspot.com
jid = xmpp.protocol.JID(xmppUsername)
xmppClient = xmpp.Client(jid.getDomain(),debug = [])
xmppClient.connect(server = _SERVER )
尝试:
xmppClient.RegisterHandler('message',XMPP_message_cb)
除了:
exitCellbot('XMPP错误,您确定手机有互联网连接?')
如果不是xmppClient:
exitCellbot('XMPP Connection failed!')
return $ b $ auth = xmppClient.auth(jid.getNode(),xmppPassword,'botty')
如果不是auth:
exitCellbot('XMPP Authentication失败!')
返回
xmppClient.sendInitPresence()
print机器人的XMPP用户名是:\ n+ xmppUsername
start = time.time ()
i = 0
try:
outputToOperator(starting)
while time.time() - start <15:
printtick
xmppClient.Process(1)
i = i + 1
if i%10 == 0:
outputToOperator(hello)
outputToOperator(退出)
除了KeyboardInterrupt:
传递
def XMPP_message_cb(session,message):
jid = xmpp.protocol.JID(message.getFrom())
全局运算符
command = message.getBody()
打印命令
def outputToOperator(msg):
printOutputting+ msg +to+ operator
xmppClient.send(xmpp.Message(operator,msg))
2)发送聊天类型的消息:
xmppClient.send(xmpp.Message(operator,msg,typ ='chat'))
有些客户对收到正常没有类型
属性。
Hey Guys, I seem to be having trouble using the xmpppy client when sending messages to the app engine's xmpp client. I am not getting any errors. The messages just aren't arriving there. Sending messages from app engine's client to the sl4a client works. Sending messages to and from google talk's client to and from the sl4a client works as well.
Any help would be greatly appreciated.
Here is the python code
import xmpp
import time
_SERVER = 'talk.google.com', 5223
commandByXMPP()
def commandByXMPP():
global xmppUsername
xmppUsername = 'garrowsbot@gmail.com'
global xmppPassword
xmppPassword = 'obscured'
global xmppClient
global operator
operator = "cellbotmote@appspot.com"
jid = xmpp.protocol.JID(xmppUsername)
xmppClient = xmpp.Client(jid.getDomain(), debug=[])
xmppClient.connect(server=_SERVER)
try:
xmppClient.RegisterHandler('message', XMPP_message_cb)
except:
exitCellbot('XMPP error. You sure the phone has an internet connection?')
if not xmppClient:
exitCellbot('XMPP Connection failed!')
return
auth = xmppClient.auth(jid.getNode(), xmppPassword, 'botty')
if not auth:
exitCellbot('XMPP Authentication failed!')
return
xmppClient.sendInitPresence()
print "XMPP username for the robot is:\n" + xmppUsername
start=time.time()
i=0
try:
outputToOperator("starting")
while time.time()-start<15:
print "tick"
xmppClient.Process(1)
i = i +1
if i % 10 == 0:
outputToOperator("hello")
outputToOperator("exiting")
except KeyboardInterrupt:
pass
def XMPP_message_cb(session, message):
jid = xmpp.protocol.JID(message.getFrom())
global operator
command = message.getBody()
print command
def outputToOperator(msg):
print "Outputting "+msg+" to " + operator
xmppClient.send(xmpp.Message(operator, msg))
1) Check that garrowsbot@gmail.com is on the roster for cellbotmote@appspot.com. GTalk won't deliver messages from unknown users. 2) Send a message of type chat:
xmppClient.send(xmpp.Message(operator, msg, typ='chat'))
Some clients do not react well to receiving "normal" messages, which don't have a type
attribute.
这篇关于Python xmpppy客户端不发送消息给appengine xmpp客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!