Python 带有.NET路由器的高速公路组件(WampSharp)
目前我正在玩WAMP原型,我很好奇这样的事情是否可能,因为我无法让它工作: 1.使用c#(WampSharp)编写WAMP路由器: 2.使用python编写组件:Python 带有.NET路由器的高速公路组件(WampSharp),python,autobahnws,wampsharp,Python,Autobahnws,Wampsharp,目前我正在玩WAMP原型,我很好奇这样的事情是否可能,因为我无法让它工作: 1.使用c#(WampSharp)编写WAMP路由器: 2.使用python编写组件: import random from twisted.internet.defer import inlineCallbacks from autobahn.twisted.util import sleep from autobahn.twisted.wamp import ApplicationSession, Applicati
import random
from twisted.internet.defer import inlineCallbacks
from autobahn.twisted.util import sleep
from autobahn.twisted.wamp import ApplicationSession, ApplicationRunner
class Component(ApplicationSession):
"""
An application component that publishes events with no payload
and with complex payload every second.
"""
@inlineCallbacks
def onJoin(self, details):
print("session attached")
counter = 0
while True:
num = random.randint(0, 100)
print("publishing : com.myapp.topic1", num)
self.publish(u'com.myapp.topic1', num)
counter += 1
yield sleep(1)
if __name__ == '__main__':
runner = ApplicationRunner(url=u"ws://127.0.0.1:9999/wsdemo", realm=u"realm1")
runner.run(Component)
当我运行python脚本时,我得到一个错误:
2017-02-20T19:49:46+0100 Main loop terminated.
2017-02-20T19:49:46+0100 Traceback (most recent call last):
2017-02-20T19:49:46+0100 File "C:\Program Files (x86)\JetBrains\PyCharm Educational Edition 1.0.1\helpers\pydev\pydevd.py", line 2199, in <module>
2017-02-20T19:49:46+0100 globals = debugger.run(setup['file'], None, None)
2017-02-20T19:49:46+0100 File "C:\Program Files (x86)\JetBrains\PyCharm Educational Edition 1.0.1\helpers\pydev\pydevd.py", line 1638, in run
2017-02-20T19:49:46+0100 pydev_imports.execfile(file, globals, locals) # execute the script
2017-02-20T19:49:46+0100 File "D:/Programming/Astronomy/Dev/ZenithPlatform/backbone/local/tests/wamp.py", line 41, in <module>
2017-02-20T19:49:46+0100 runner.run(Component)
2017-02-20T19:49:46+0100 File "C:\Python27\lib\site-packages\autobahn\twisted\wamp.py", line 312, in run
2017-02-20T19:49:46+0100 raise connect_error.exception
2017-02-20T19:49:46+0100 twisted.internet.error.ConnectionRefusedError: Connection was refused by other side: 10061: No connection could be made because the target machine actively refused it..
2017-02-20T19:49:46+0100主回路终止。
2017-02-20T19:49:46+0100回溯(最近一次呼叫最后一次):
2017-02-20T19:49:46+0100文件“C:\Program Files(x86)\JetBrains\PyCharm教育版1.0.1\helpers\pydev\pydevd.py”,第2199行,在
2017-02-20T19:49:46+0100 globals=debugger.run(安装程序['file'],无,无)
2017-02-20T19:49:46+0100文件“C:\Program Files(x86)\JetBrains\PyCharm教育版1.0.1\helpers\pydev\pydevd.py”,第1638行,正在运行
2017-02-20T19:49:46+0100 pydev_imports.execfile(file,globals,locals)#执行脚本
2017-02-20T19:49:46+0100文件“D:/Programming/Astronomy/Dev/ZenithPlatform/backbone/local/tests/wamp.py”,第41行,in
2017-02-20T19:49:46+0100转轮运行(部件)
2017-02-20T19:49:46+0100文件“C:\Python27\lib\site packages\autobahn\twisted\wamp.py”,第312行,正在运行
2017-02-20T19:49:46+0100上升连接错误。异常
2017-02-20T19:49:46+0100 twisted.internet.error.ConnectionRefusedError:连接被另一方拒绝:10061:无法建立连接,因为目标计算机主动拒绝了它。。
依照
我们创建的组件试图连接到WAMP路由器
在本地运行,接受端口8080上的连接,并且
领域1
我们建议使用Crossbar.io作为WAMP路由器。有
除了Crossbar.io,还有其他WAMP路由器
这样的事情能实现吗
谢谢,Civa您的using语句在程序结束前处理路由器 只需添加一个Console.ReadLine();在Console.WriteLine()语句之后的使用范围内的语句。这应该行。您的using语句会在程序结束前处理路由器
只需添加一个Console.ReadLine();在Console.WriteLine()语句之后的使用范围内的语句。那应该行。哦,亲爱的上帝当我快速复制演示代码以赢得应用程序时,我完全忽略了这一点。非常感谢!哦,亲爱的上帝当我快速复制演示代码以赢得应用程序时,我完全忽略了这一点。非常感谢!
2017-02-20T19:49:46+0100 Main loop terminated.
2017-02-20T19:49:46+0100 Traceback (most recent call last):
2017-02-20T19:49:46+0100 File "C:\Program Files (x86)\JetBrains\PyCharm Educational Edition 1.0.1\helpers\pydev\pydevd.py", line 2199, in <module>
2017-02-20T19:49:46+0100 globals = debugger.run(setup['file'], None, None)
2017-02-20T19:49:46+0100 File "C:\Program Files (x86)\JetBrains\PyCharm Educational Edition 1.0.1\helpers\pydev\pydevd.py", line 1638, in run
2017-02-20T19:49:46+0100 pydev_imports.execfile(file, globals, locals) # execute the script
2017-02-20T19:49:46+0100 File "D:/Programming/Astronomy/Dev/ZenithPlatform/backbone/local/tests/wamp.py", line 41, in <module>
2017-02-20T19:49:46+0100 runner.run(Component)
2017-02-20T19:49:46+0100 File "C:\Python27\lib\site-packages\autobahn\twisted\wamp.py", line 312, in run
2017-02-20T19:49:46+0100 raise connect_error.exception
2017-02-20T19:49:46+0100 twisted.internet.error.ConnectionRefusedError: Connection was refused by other side: 10061: No connection could be made because the target machine actively refused it..