Skip to Content

SAP Hana Express (VM) : websocket tutorials

Hello

I am trying the Hana Express tutorials about websockets.

I have followed the explanations, copied the files and built with no error.

But when I run the application, my Websocket connection close immediately (message displayed in pop-up).

Can anyone help ?

Regards

Emmanuel

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Nov 18, 2016 at 02:58 AM

    Hello Emmanuel:

    Can you please post any message you are seeing in the console.

    Also, can you try modifying the following block:

    wss.on("connection", function (ws) {
        	ws.on("message", function (message) {
            	console.log("received: %s", message);
            	wss.broadcast(message);
    		});
        	ws.send(JSON.stringify({
            	user: "XS",
            	text: "Hello from Node.js XS Server"
        	}));
    	});

    to include some logging for the open and close methods to see if you were able to open the socket.

    wss.on("connection", function (ws) {
        	ws.on("message", function (message) {
            	console.log("received: %s", message);
            	wss.broadcast(message);
    		});
        	ws.send(JSON.stringify({
            	user: "XS",
            	text: "Hello from Node.js XS Server"
        	}));
            ws.on('open', function open() { console.log('connected') }); 
            ws.on('close', function close() { console.log('disconnected'); });
    	});
    Add comment
    10|10000 characters needed characters exceeded