You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cannot create two servers in the same node instance.
Steps to reproduce (if the current behaviour is a bug)
This test fails.
The wsServer2 cannot be created, we get a exception caught in the try catch block. The strange is that the 1st server, the wsServer1 is created with no exception.
Probably the creation should be done with different way... but how?
var http = require('http');
var engineIo = require('engine.io');
var httpServer1;
var httpServer2;
var wsServer1;
var wsServer2;
describe('socket.io test basics', function () {
it('should create server 1', function () {
try {
httpServer1 = http.createServer();
wsServer1 = engineIo(httpServer1);
httpServer1.listen(34001);
expect(true).toBe(true);
}
catch (error) {
console.error('cannot create server 1', error);
expect(!!error).toBe(false);
}
});
it('should create server 2', function () {
try {
httpServer2 = http.createServer();
wsServer2 = engineIo(httpServer2);
httpServer2.listen(34002);
expect(true).toBe(true);
}
catch (error) {
console.error('cannot create server 2', error);
expect(!!error).toBe(false);
}
});
});
The exception is this:
TypeError: wsModule.Server is not a constructor
at Server.Object.<anonymous>.Server.init (L:\myApp\node_modules\engine.io\lib\server.js:121:13)
at new Server (L:\myApp\node_modules\engine.io\lib\server.js:65:8)
at attach (L:\myApp\node_modules\engine.io\lib\engine.io.js:123:16)
at Object.<anonymous>.module.exports (L:\myApp\node_modules\engine.io\lib\engine.io.js:24:19)
at Object.it (L:\myApp\tests\socket.io.test.ts:26:25)
at Object.asyncFn (L:\myApp\node_modules\jest-jasmine2\build\jasmine-async.js:68:30)
at resolve (L:\myApp\node_modules\jest-jasmine2\build\queueRunner.js:38:12)
at mapper (L:\myApp\node_modules\jest-jasmine2\build\queueRunner.js:31:21)
at Promise.resolve.then.el (L:\myApp\node_modules\p-map\index.js:42:16)
at process._tickCallback (internal/process/next_tick.js:103:7)
Expected behaviour
No errors. the 2nd server should be created as the first one did.
Setup
OS: window
browser: nodejs 7.2.0
engine.io version: 2.0.3
Other information (e.g. stacktraces, related issues, suggestions how to fix)
The text was updated successfully, but these errors were encountered:
I've had the same issue. It seems that it is a issue with uws. If it fails to use uws it will fallback to ws (expection is thrown and catched). If this happens a second time the fallback fails (exception is not thrown) but the wsModule is set to undefined. Therefor the error.
You want to:
Current behaviour
Cannot create two servers in the same node instance.
Steps to reproduce (if the current behaviour is a bug)
This test fails.
The wsServer2 cannot be created, we get a exception caught in the try catch block. The strange is that the 1st server, the wsServer1 is created with no exception.
Probably the creation should be done with different way... but how?
The exception is this:
Expected behaviour
No errors. the 2nd server should be created as the first one did.
Setup
Other information (e.g. stacktraces, related issues, suggestions how to fix)
The text was updated successfully, but these errors were encountered: