升级到最新版本后,wamp.session.get挂起

时间:2019-01-18 15:51:41

标签: python crossbar wamp-protocol

升级到最新版本的crossbar.io之后,下面的Python程序挂在对wamp.session.get的调用上。之前的所有代码(包括对wamp.session.list的调用)都可以正常工作,并且wamp.session.list返回有效的会话ID列表。

该程序的目的是检查指定IP地址的加密货币挖掘服务器是否已连接到WAMP,并从其硬币中接收新的区块。 OpenNMS监视系统将调用此程序,并且当它指示未连接服务器时,将唤醒某人以解决问题。通话开始挂起时,正在运行此程序的服务器上没有任何升级。

from twisted.internet import reactor, defer
from autobahn.twisted.wamp import ApplicationRunner
from autobahn.twisted.wamp import ApplicationSession
from autobahn.wamp import auth
import sys, traceback, os
import socket

DAEMON_URL = u'censored'
DAEMON_REALM = u'censored'
DAEMON_USERNAME = u'censored'
DAEMON_PASSWORD = u'censored'

class DaemonRealmSession(ApplicationSession):
    def onConnect(self):
        print "Connected."
        self.join(self.config.realm, [u"wampcra"], DAEMON_USERNAME)

    @defer.inlineCallbacks
    def onJoin(self, details):
        try:
            print "Joined realm."

            if len(sys.argv) < 2:
                print "No IP address was provided as an argument.  Exit status is 1."
                os._exit(1)

            ip_address = sys.argv[1]
            session_list = yield self.call(u'wamp.session.list')

            #Search through the list and find at least two connections from this IP.
            for session_id in session_list:
                try:
                    session_info = yield self.call(u'wamp.session.get', session_id)
                except Exception, ex:
                    os._exit(1)

                split_peer = session_info['transport']['peer'].split(":")
                peer_ip = split_peer[1]

                if peer_ip == ip_address:
                    os._exit(0)

        except Exception:
            traceback.print_exc()
            os._exit(1)

        reactor.stop()


    def onChallenge(self, challenge):
        try:
            if challenge.method == "wampcra":
                if 'salt' in challenge.extra:
                    key = auth.derive_key(DAEMON_PASSWORD.encode('utf8'),
                                      challenge.extra['salt'].encode('utf8'),
                                      challenge.extra.get('iterations', None),
                                      challenge.extra.get('keylen', None))
                else:
                    key = DAEMON_PASSWORD.encode('utf8')
                signature = auth.compute_wcs(key, challenge.extra['challenge'].encode('utf8'))
                return signature.decode('ascii')
            else:
                raise Exception("don't know how to compute challenge for authmethod {}".format(challenge.method))
        except Exception:
            traceback.print_exc()
            reactor.stop()

daemon_runner = ApplicationRunner(url=DAEMON_URL, realm=DAEMON_REALM)
daemon_runner.run(DaemonRealmSession, start_reactor=False, log_level='debug', auto_reconnect=True)
reactor.run()

#If the code gets here, then the IP address wasn't found.
os._exit(1)

不幸的是,我找不到任何文档来揭示如何找到服务器上运行的交叉开关的版本。该版本是12月15日从Debian 9稳定版本库中发布的版本。

交叉开关中的哪些变化导致wamp.session.get在该版本中停止响应?

0 个答案:

没有答案