Autobahn 0.9.5(AMD)-WebSocket握手时出错
我正在尝试使用DurandalJS在我的SPA项目上实现 我在firefox和chrome浏览器上收到一个错误 火狐: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
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)代码>
- 它从
- 高速公路的全局变量为autobahn
- 连接到
新高速公路。连接({url:wuri,realm:yourRealm})代码>
<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']
}
}
});