将Punjab设置为Facebook聊天的BOSH XMPP代理



我想使用Punjab作为Facebook聊天的xmpp代理

旁遮普邦运行良好,但当我问chat.facebook.com时,它不起作用

SENT: <body rid='313820892' xmlns='http://jabber.org/protocol/httpbind' to='chat.facebook.com' xml:lang='en' wait='300' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xml='http://www.w3.org/XML/1998/namespace' xmlns:xmpp='urn:xmpp:xbosh'/>
RECV: <body xmlns='http://jabber.org/protocol/httpbind' type='terminate' condition='remote-connection-failed'/>

当我们查看punjab日志时,我们可能会看到punjap连接到chat.facebook.com,但没有任何答案

2012/03/09 10:42 +0200 [-] Log opened.
2012/03/09 10:42 +0200 [-] twistd 2.5.0 (/usr/bin/python 2.5.0) starting up
2012/03/09 10:42 +0200 [-] reactor class: <class 'twisted.internet.selectreactor.SelectReactor'>
2012/03/09 10:42 +0200 [-] Loading punjab.tac...
2012/03/09 10:42 +0200 [-] twisted.web.server.Site starting on 5281
2012/03/09 10:42 +0200 [-] Starting factory <twisted.web.server.Site instance at 0xb785c58c>
2012/03/09 10:42 +0200 [-] Loaded.
2012/03/09 10:42 +0200 [-] twisted.web.server.Site starting on 5280
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] HEADERS 1331282556.16:
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] {'origin': 'http://mydomain.tld', 'content-length': '264', 'via': '1.1 mydomain.tld', 'accept-language': 'fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4', 'accept-encoding': 'gzip,deflate,sdch', 'x-forwarded-host': 'mydomain.tld', 'x-forwarded-for': 'XXX.XXX.XXX.XXX', 'connection': 'Keep-Alive', 'accept': '*/*', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/11.10 Chromium/17.0.963.65 Chrome/17.0.963.65 Safari/535.11', 'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'host': 'localhost:5280', 'referer': 'http://mydomain.tld/facebook/', 'max-forwards': '10', 'cookie': '_jsuid=2679835210; fbm_XXXXXXXXX=base_domain=.mydomain.tld; fbsr_XXXXXXXXX=XXXXXXXXX', 'x-forwarded-server': 'mydomain.tld', 'content-type': 'application/xml'}
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] HTTPB POST : 
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] <body rid='XXXXXXXXX' xmlns='http://jabber.org/protocol/httpbind' to='chat.facebook.com' xml:lang='en' wait='300' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xml='http://www.w3.org/XML/1998/namespace' xmlns:xmpp='urn:xmpp:xbosh'/>
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] Session Created : afeb0b2bf66d6ca8b5f5fee83ebbb449b64f4c65 1331282556.16
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] ================================== 1331282556.17 connect to chat.facebook.com:5222 ==================================
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] Starting factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [HTTPChannel,0,127.0.0.1] twisted.names.dns.DNSDatagramProtocol starting on 55647
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] <punjab.session.XMPPClientConnector instance at 0xb77e4f6c> will retry in 3 seconds
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] Stopping factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [-] Starting factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] <punjab.session.XMPPClientConnector instance at 0xb77e4f6c> will retry in 10 seconds
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] Stopping factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [-] Starting factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] Abandoning <punjab.session.XMPPClientConnector instance at 0xb77e4f6c> after 3 retries.
2012/03/09 10:42 +0200 [twisted.names.dns.DNSDatagramProtocol (UDP)] Stopping factory <punjab.session.Session instance at 0xb77e4eac>
2012/03/09 10:43 +0200 [-] ================================== afeb0b2bf66d6ca8b5f5fee83ebbb449b64f4c65 1331282584.43 startup timeout ==================================
2012/03/09 10:43 +0200 [-] HTTPB Error 200
2012/03/09 10:43 +0200 [-] HTTPB Return Error: 200 -> <body xmlns='http://jabber.org/protocol/httpbind' type='terminate' condition='remote-connection-failed'/>

我的punjab-tac文件与脸书的ssl配置:

# punjab tac file
from twisted.web import server, resource, static
from twisted.application import service, internet
from twisted.internet import reactor, ssl
from punjab.httpb  import Httpb, HttpbService
root = static.File("./html")
bosh = HttpbService(1)
root.putChild('http-bind', resource.IResource(bosh))
site  = server.Site(root)
application = service.Application("punjab")
internet.TCPServer(5280, site).setServiceParent(application)
#
# RMW adding TLS support for Facebook chat/xmpp support
#
sslContext = ssl.DefaultOpenSSLContextFactory(
        '/root/punjab_privkey.pem',
        '/root/punjab_cacert.pem',
)
reactor.listenSSL(
        5281,
        site,
        contextFactory=sslContext,
)

你知道为什么我在chat.facebook.com上没有任何答案吗?

感谢

我找到了答案我在punjab.tac中添加了这一行,以获得正确的DNS外观

bosh.connect_srv = False

就在这条线路之后

bosh = HttpbService(1)

您可以完全禁用证书验证(警告:INSECURE)

将其放入punjab.tac文件

from twisted.internet import _sslverify
_sslverify.platformTrust = lambda : None

最新更新