Tag: autobahn

AutobahnJS:远程调用asynchronous函数

我试图通过WAMP拨打一个远程function。 但是如果它有asynchronous行为,我不知道如何编写被调用的函数。 在我看到的每个例子中,远程函数都返回结果。 如何以asynchronous的方式来完成,我通常会使用callback? 例子:这是一个函数的注册,它将asynchronous获取文件的内容。 session.register('com.example.getFileContents', getFileContents).then( function (reg) { console.log("procedure getFileContents() registered"); }, function (err) { console.log("failed to register procedure: " + err); } ); 以下是我将如何远程调用该function。 session.call('com.example.getFileContents', ["someFile.txt"]).then( function (res) { console.log("File Contents:", res); }, function (err) { console.log("Error getting file contents:", err); } ); 但是这是注册的实际function。 function getFileContents(file) { fs.readFile(file, 'utf8', function(err, data) { […]

在autobahn onclose事件时重新连接

我有一些我正在testing的高速公路代码,包括一个onopen事件和一个onclose事件。 我已经注意到更新将停止,但是我的代码将继续运行,所以我怀疑连接正在丢失。 我更新了onclose事件存在为每个: connection.onclose = (reason, details) => { console.log("REASON", reason); console.log("DETAILS", details); reject(reason); process.exit(); }; 当连接丢失时,我现在得到: REASON lost DETAILS { reason: null, message: null, retry_delay: 1.3305311206405022, retry_count: 1, will_retry: true } 有无论如何我可以响应这个事件,并重新build立连接或我的“process.exit()”行停止这种自动发生?

Autobahn.JS掉线

我有一个Crossbar.js实现,在客户端(网站)和服务器(Node.js)之间通过Crossbar websocket服务器发送数据。 双方都使用Autobahn.JS连接到Crossbar服务器。 连接工作正常,但似乎客户端和服务器断断续续,随机时刻重新连接。 这大约每两分钟发生一次。 我也看到,双方的连接并没有同时发生。 这让我觉得问题在于我在双方使用的Autobahn实现(对于客户端和服务器来说大致相同)。 下面是我用来从Node.js连接到Crossbar服务器的方法。 浏览器的版本几乎完全相同。 我只改变了订阅,并改变了const并letvariablesvar 。 start(connectionConfig) { const self = this; self.host = connectionConfig.host; self.realm = connectionConfig.realm; self.channelPrefix = connectionConfig.channelPrefix; try { // Start an Autobahn websocket connection self.connection = new autobahn.Connection({"url": self.host, "realm": self.realm}); self.connection.onopen = function(session) { // Save session in class self.session = session; // Listen […]

高速公路VS Einaros – 节点JS的Websockets

我需要编写一个WebSocket服务器,并通过阅读我购买的书籍来学习Node JS。 这个服务器是一个非常快的游戏,所以我需要尽可能快地将小消息stream到客户组。 有什么区别: 高速公路| JS: http : //autobahn.ws/js/ 和 Einaros: https : //github.com/einaros/ws ? 我听说高速公路非常强大,能够在没有负载平衡器的情况下处理200k客户端,所以我想知道是否有更多经验的人可以告诉我在select一个或另一个库时是否有优势。

React-Native和AutobahnJS

我正尝试使用npm包react-native-autobahnjs在React-Native应用程序中与WebSocket服务器build立连接。 这是我的代码: import autobahn from 'react-native-autobahnjs'; class websocket extends Component { componentWillMount () { console.warn("MOUNTING MAIN COMPONENT"); const connection = new autobahn.Connection({ url: 'wss://myserver/ws', realm: 'realm1' }); connection.onopen = () => { console.warn("onopen"); }; connection.onclose = (reason, details) => { console.warn("onclose : reason = " + reason + ", details = " + details); }; […]

高速公路(节点)不检测掉连接,无限等待,我可以设置超时?

我在节点中使用AutobahnJS代码来接收来自服务的数据。 它工作得很好,每秒获得多个事件。 当我的networking暂时断开连接时,Autobahn没有检测到丢失的连接,也没有写入“Websocket connection dropped”到控制台,它只是挂起。 下去。 是否有可以设置的超时,如果1分钟后没有数据到达,重新连接? 或者我可以使用setTimeout函数来ping服务器,如果没有pong返回closures连接,并尝试重新打开它? 我search了一下,直到我的手指stream血,但是我没有find这个问题的直接答案。 非常感谢你! connection.onopen = function(session) { session.subscribe(arg, someEvent); } connection.onclose = function() { console.log("Websocket connection dropped"); } connection.open();

无法在我的node.js项目的wamp套接字中configurationssl

我用angular-wamp作为客户端, Crossbar作为路由器。 当我没有ssl(https)使用它时,WAMP是完美的工作。 但是当我试图实现安全的WebSocket它给这样的错误在控制台中: WAMP connection closed unreachable { reason: null, message: null, retry_delay: 2.052066390813223, retry_count: 2, will_retry: true } 但在浏览器中显示恭喜! 你连接到WAMP服务器! 我已经使用wss:// localhost:8080 / ws作为连接的URL。 使用此链接作为参考https://github.com/crossbario/crossbarexamples Node.js服务器在3000端口上运行。 卡住严重,任何帮助将不胜感激。 我已经接受了本地主机以及127.0.0.1的临时不安全authentication(通常是我们的自我authentication),但仍然得到了以下的东西。 在浏览器日志中: 恭喜! 你连接到WAMP服务器! 我已经接受了自签名authentication(localhost和127.0.0.1):