Monday, 29 May 2017

Node server segmentation fault (core dumped), When it receives websocket connection request

I am using Node sever with Socketio to make a simple chat application. my website is SSL. I am using apache server with proxy to Node server for websocket connections. When my node server receives first request using polling, it make a successful connection. On client side connection event is called and I can also see socket.id but right after it when socketio internal functionality tries to upgrade the connection to websocket.. Node server crashes with an error on the terminal Segmentation fault (Core dumped) Just this... I am new to node.js and socket io. help me how can I solve this issue.. and also tell me if there is a way to debug the server using shell commands, as I don't have desktop access to my server. I only connect to it with SSH access..

Here is my server code

var fs = require('fs');
var https = require('https');
var express = require('express');
var app = express();
var options = {
  key: fs.readFileSync('apache-selfsigned.key'),
  cert: fs.readFileSync('apache-selfsigned.crt')
};
var serverPort = 9001;

var server = https.createServer(options, app);
var io = require('socket.io')(server);

io.on('connection', function(socket) {
  console.log('new secure connection');
  socket.on('chat message', function(msg){
    io.emit('chat message', msg);
  });
});
server.listen(serverPort, function() {
  console.log('server up and running at %s port', serverPort);
});

here is my client code

socket = io('https://www.MyApacheServer.net/');
socket.on('connect', function(){
    console.log("Connected");
    console.log(socket.id);
});
socket.on('disconnect', function(){
    console.log("DisConnected");
});
socket.on('error', function (e) {
    console.log('System', e ? e : 'A unknown error occurred');
});
socket.on('chat message', function(msg){
    alert(msg);
});



via Nauman Nasir

No comments:

Post a Comment