0

I wanted to test deepstream with express. Found this template https://github.com/deepstreamIO/ds-tutorial-express

But when I run it I get the error message: Connection closed before receiving a handshake response

Why isn't this example working?

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

Jedi Schmedi
  • 746
  • 10
  • 36
  • The attached tutorial is no longer valid since, there's no 'httpServer' key in the 2.0 api. For anybody who ends up here, please refer to the documentation and run deepstream as a standalone server. Although you may use a reverse proxy set up. – Arvind Mar 01 '18 at 10:24

1 Answers1

0

On the client, could you switch to this CDN link

<script src="https://cdnjs.cloudflare.com/ajax/libs/deepstream.io-client-js/1.1.1/deepstream.js"></script>

the rawgit one is pointing to the master branch which is already at 2.0 and incompatible with the 1.x server

wolframhempel
  • 1,094
  • 10
  • 12