Autobahn 0.9.5(AMD)-WebSocket握手时出错

Autobahn 0.9.5(AMD)-WebSocket握手时出错,websocket,durandal,durandal-2.0,autobahn,autobahnws,Websocket,Durandal,Durandal 2.0,Autobahn,Autobahnws,我正在尝试使用DurandalJS在我的SPA项目上实现 我在firefox和chrome浏览器上收到一个错误 火狐: InvalidAccessError: A parameter or an operation is not supported by the underlying object websocket.close(code, reason); 铬: WebSocket connection to 'ws://localhost:8080/' failed: Error du

我正在尝试使用DurandalJS在我的SPA项目上实现

我在firefox和chrome浏览器上收到一个错误

火狐:

 InvalidAccessError: A parameter or an operation is not supported by the underlying object
 websocket.close(code, reason);
铬:

WebSocket connection to 'ws://localhost:8080/' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received 
我不知道发生了什么事

在我开始之前-高速公路0.9.5

我在test.html上写了一个简单的测试,看看后端的所有设置是否正确。
但在这次测试中,我目前使用的是高速公路0.8.2

test.html

<script src="http://autobahn.s3.amazonaws.com/js/autobahn.min.js"></script>
<script>
    var conn = new ab.Session(

        // Websocket host
        'ws://localhost:8080',

        // Callback on connection established
        function() {
            // Once connect, subscribe to channel
            conn.subscribe('3', function(topic, data) {
                console.log(topic, data);              
            });
        },

        // Callback on connection close
        function() {
            console.warn('WebSocket connection closed');
        },

        // Additional AB parameters
        {'skipSubprotocolCheck': true}
    );
</script>
希望有人能帮助我,我真的很喜欢让它工作

任何帮助都将不胜感激!
谢谢

可能晚了,但请进一步参考

这可能不是对这个问题的完整答案

首先,应为AutobahnJS v0.8.2(支持WAMPv1)或AutobahnJS v0.9.5(WAMPv2)编写所有内容

检查API文档

WAMP v1

  • 它从
  • 高速公路的全局变量为ab
  • 连接
    var conn=new ab.Session(wuri、onOpenCallback、onCloseCallback、options)
WAMP v2

  • 它从
  • 高速公路的全局变量为autobahn
  • 连接到
    新高速公路。连接({url:wuri,realm:yourRealm})

谢谢@MrW,我已经成功地让它工作了!导致我无法连接的原因(返回错误)是我们在后端内容中遗漏的。所以,我投票给你作为一个很好的参考!非常感谢。这对我自己来说也很有帮助,在阅读了很多之后。嘿,是什么问题导致了这两个错误?我正在用RatchetPHP编写一个应用程序,在使用最新的Autobahn和玩他们的“Get sarted”时,我也出现了同样的两个错误,但该应用程序似乎在0.8.2上运行良好:(
<script src="http://autobahn.s3.amazonaws.com/js/autobahn.min.js"></script>
<script>
    var conn = new ab.Session(

        // Websocket host
        'ws://localhost:8080',

        // Callback on connection established
        function() {
            // Once connect, subscribe to channel
            conn.subscribe('3', function(topic, data) {
                console.log(topic, data);              
            });
        },

        // Callback on connection close
        function() {
            console.warn('WebSocket connection closed');
        },

        // Additional AB parameters
        {'skipSubprotocolCheck': true}
    );
</script>
requirejs.config({
  paths: {
      'autobahn'          : 'https://autobahn.s3.amazonaws.com/autobahnjs/latest/autobahn.min',
      'when'              : 'https://cdnjs.cloudflare.com/ajax/libs/when/2.7.1/when'
  },
  shim: {
     'autobahn': {
         deps: ['when']
     }
  }
});