cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Hana Express (VM) : websocket tutorials

former_member25364
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

carlsoane
Participant
0 Kudos

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'); });
	});
former_member25364
Participant
0 Kudos

Thank for your help.

I close the thread.

Regards

Emmanuel

Answers (0)