Search code examples
expressdeepstream.io

Connection closed before receiving a handshake response with deepstream + express


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


Solution

  • 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