Skip to Content
0

SAP Hana Express (VM) : websocket tutorials

Oct 26, 2016 at 04:27 AM

154

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Carl Soane
Nov 18, 2016 at 02:58 AM
0

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'); });
	});
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank for your help.

I close the thread.

Regards

Emmanuel

0