javascriptnode.jsjxcore

WebSocket not working with Nexe


I have built a NodeJS application and I am using Websocket to send events to Browser. Now I need to bundle the Node Application into EXE and send to client.
I tried nexe and JXCore but nexe is bundling the application but giving issue when i am trying to run it.
The JS code for Websocket is

var WebSocketServer = require('websocket').server;
var http = require('http');

var server = http.createServer(function(request, response) {
    console.log((new Date()) + ' Received request for ' + request.url);
    response.writeHead(404);
    response.end();
});
server.listen(1337, function() {
    console.log((new Date()) + ' Server is listening on port 8080');
});

wsServer = new WebSocketServer({
    httpServer: server,
    // You should not use autoAcceptConnections for production 
    // applications, as it defeats all standard cross-origin protection 
    // facilities built into the protocol and the browser.  You should 
    // *always* verify the connection's origin and decide whether or not 
    // to accept it. 
    autoAcceptConnections: false
});

wsServer.on('request', function(request) {
    var connection = request.accept(null, request.origin);
    eze.ee.on("EPIC_VALIDATING_DEVICE"  ,       function()                  {connection.sendUTF('VAlidate')});

The Exception stack is as follows

 nexe.js:15318
 wsServer = new WebSocketServer({
   ^

TypeError: WebSocketServer is not a function
    at Array.__dirname.call.C:\Users\Raghav Tandon\WinPos\BrowserIntegrat
ion\js\RestImpl.js.http (nexe.js:15318:12)
    at initModule (nexe.js:29:11)
    at nexe.js:31:64
    at Array.__dirname.call.C:\Users\Raghav Tandon\WinPos\BrowserIntegrat
ion\js\RestWS.js../RestImpl (nexe.js:48:20)
    at initModule (nexe.js:29:11)
    at Array.forEach (native)
    at nexe.js:39:8
    at nexe.js:46:4
    at NativeModule.compile (node.js:945:5)
    at Function.NativeModule.require (node.js:893:18)

Why this is not loading Webscocket module? I have tested the application as node start and it is working properly.


Solution

  • This is happening because of Nexe is not able to support native modules. Rather I tried Electron which works like a charm and has support for Native modules as well.