在使用deepstream + express接收握手响应之前,连接已关闭

时间:2016-11-16 11:51:58

标签: express deepstream.io

我想用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

1 个答案:

答案 0 :(得分:0)

在客户端上,您是否可以切换到此CDN链接

admin

rawgit指向主分支,它已经是2.0并且与1.x服务器不兼容