在收到与 deepstream + express 的握手响应之前连接关闭
Connection closed before receiving a handshake response with deepstream + express
我想用 express 测试 deepstream。
找到这个模板 https://github.com/deepstreamIO/ds-tutorial-express
但是当我 运行 它时,我收到错误消息:
连接在收到握手响应前关闭
为什么这个例子不起作用?
Server.js
var Deepstream = require( 'deepstream.io' );
var http = require( 'http' );
var express = require( 'express' );
var deepstream = new Deepstream();
var app = express();
var server = http.createServer(app);
app.get('/hello', function ( req, res ) {
res.send( 'Hello to you too!' );
})
deepstream.set( 'httpServer', server );
deepstream.start();
server.listen( 6020, function(){
console.log( 'HTTP server listening on 6020' );
});
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example Client</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- libraries -->
<script type="text/javascript" src="https://rawgit.com/deepstreamIO/deepstream.io-client-js/master/dist/deepstream.min.js"></script>
</head>
<body>
<script>
var ds = deepstream( 'localhost:6020' );
ds.login( {}, function( success, errorEvent, errorMessage ) {
console.log( 'Logged in to deepstream' );
});
</script>
</body>
</html>
BR
在客户端,能不能切换到这个CDNlink
<script src="https://cdnjs.cloudflare.com/ajax/libs/deepstream.io-client-js/1.1.1/deepstream.js"></script>
rawgit 指向已经是 2.0 且与 1.x 服务器不兼容的 master 分支
我想用 express 测试 deepstream。 找到这个模板 https://github.com/deepstreamIO/ds-tutorial-express
但是当我 运行 它时,我收到错误消息: 连接在收到握手响应前关闭
为什么这个例子不起作用?
Server.js
var Deepstream = require( 'deepstream.io' );
var http = require( 'http' );
var express = require( 'express' );
var deepstream = new Deepstream();
var app = express();
var server = http.createServer(app);
app.get('/hello', function ( req, res ) {
res.send( 'Hello to you too!' );
})
deepstream.set( 'httpServer', server );
deepstream.start();
server.listen( 6020, function(){
console.log( 'HTTP server listening on 6020' );
});
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example Client</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- libraries -->
<script type="text/javascript" src="https://rawgit.com/deepstreamIO/deepstream.io-client-js/master/dist/deepstream.min.js"></script>
</head>
<body>
<script>
var ds = deepstream( 'localhost:6020' );
ds.login( {}, function( success, errorEvent, errorMessage ) {
console.log( 'Logged in to deepstream' );
});
</script>
</body>
</html>
BR
在客户端,能不能切换到这个CDNlink
<script src="https://cdnjs.cloudflare.com/ajax/libs/deepstream.io-client-js/1.1.1/deepstream.js"></script>
rawgit 指向已经是 2.0 且与 1.x 服务器不兼容的 master 分支