question

Alessio Merlo avatar image
0 Likes"
Alessio Merlo asked Phil BoBo commented

Run multiple webserver instance

Hi community,

I have an issue with the webserver and I am searching a solution.

I need to run two different webservers in the same machine to support two different FlexSim versions.

If I run one webserver per time, everythings works. When I run both simultaneously, only one is initialize correctly. The second one return this error

Error:
listen EADDRINUSE: address already in use \\.\pipe\FlexsimServerRegistrationPipe
Error: listen EADDRINUSE: address already in use \\.\pipe\FlexsimServerRegistrationPipe
    at Server.setupListenHandle [as _listen2] (node:net:1855:21)
    at listenInCluster (node:net:1920:12)
    at Server.listen (node:net:2025:5)
    at Object.runServer [as run] (C:\Program Files (x86)\FlexSim Web Server 22 - CV\webserver\server.js:356:22)
    at runServer (C:\Program Files (x86)\FlexSim Web Server 22 - CV\webserver\index.js:125:16)
    at Object.<anonymous> (C:\Program Files (x86)\FlexSim Web Server 22 - CV\webserver\index.js:129:5)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)


There was a Problem with the FlexSim WebServer.
Press Enter to Exit.

I suppose that it isn't supported by webserver, but I need to confirm it. Do you have any workaround?

You can reproduce the problem in this easy way:

  1. install webserver 21.0 and configure it;
  2. install webserver 22.2 and configure it;
  3. run the webserver 21.0 (should work correctly);
  4. run the webserver 22.2 (shoudn't work);

I hope to find a solution!

FlexSim 24.0.3
webserver
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joerg Vogel avatar image Joerg Vogel commented ·

@Alessio Merlo, You need probably a different setup to get access to your webserver on a different port or a second virtual internet address.

"address already in use"
0 Likes 0 ·
Alessio Merlo avatar image Alessio Merlo Joerg Vogel commented ·

Thanks @Joerg for quick reply! But the port is not the problem.

When I use the same port the error is:

Error:
listen EADDRINUSE: address already in use :::8081
Error: listen EADDRINUSE: address already in use :::8081
    at Server.setupListenHandle [as _listen2] (node:net:1872:16)
    at listenInCluster (node:net:1920:12)
    at Server.listen (node:net:2008:7)
    at Object.runServer [as run] (C:\Program Files (x86)\FlexSim Web Server 22 - test\webserver\server.js:578:19)
    at runServer (C:\Program Files (x86)\FlexSim Web Server 22 - test\webserver\index.js:125:16)
    at Object.<anonymous> (C:\Program Files (x86)\FlexSim Web Server 22 - test\webserver\index.js:129:5)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
 
 
There was a Problem with the FlexSim WebServer.
Press Enter to Exit.

Totally different message!

I suppose that the problem is in runServer() function where the server defines the REG_PIPE_PATH. I tried to change the path, the server starts, but then nothing more works.

function runServer() {
    // registration pipe
    REG_PIPE_PATH = "\\\\.\\pipe\\FlexsimServerRegistrationPipe";
    registrationPipe = net.createServer(function(stream) {
        stream.on('data', function(message) {
            var parsedMessage = (message + "").split(",");
            var pid = parsedMessage[0];
            for(var i = 0; i < instances.length; i++) {
                if(instances[i].proc.pid == pid) {
                    // Store the instance's version before registering
                    if(parsedMessage.length > 1) {
                        instances[i].version = parsedMessage[1];
                    }

                    instances[i].registered = true;
                }
            }
        });
        stream.write('3.0.0');
    });
    registrationPipe.listen(REG_PIPE_PATH);
0 Likes 0 ·
Alessio Merlo avatar image Alessio Merlo commented ·

Does anybody help me? @Phil BoBo @Jordan Johnson

0 Likes 0 ·

1 Answer

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Phil BoBo commented

You don't need multiple webservers to support multiple FlexSim versions anymore.

Just specify the path to the Version Selector for the FlexSim program directory in the webserver configuration file:

1716472466743.png


1716472466743.png (231.4 KiB)
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Alessio Merlo avatar image Alessio Merlo commented ·
Hi @ Phil,

I need to keep alive two different webserver instances because they allow two different workflows from the user perspective. I can't simply switch from one FlexSim version to another one.

My framework is:

- webserver 21.0 with FlexSim 22.0 with a dedicated module and library;

- webserver 22.2 with FlexSim 24.0 with a dedicated module and library;

In the future I will migrate all libraries and modules to the same FlexSim version, but I can't do it now.

Rigth now I would like to different address to reach the server and manage the workflow separately.

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Alessio Merlo commented ·

You can do that with the version selector.

If you want to open the "FlexSim 22.0 with a dedicated module and library," then load an fsm that was saved in version 22. It will open that FlexSim.

If you want to open the "FlexSim 24.0 with a dedicated module and library," then load an fsm that was saved in version 24. It will open that FlexSim.

Instead of having to specify a different webserver port for each different FlexSim version, you can specify the FlexSim version to open based on the version saved in the fsm that you are trying to open. That's the point of the version selector.

In the future I will migrate all libraries and modules to the same FlexSim version, but I can't do it now.

You don't need to do that now. If you use the version selector, then the same webserver can open different FlexSim versions with different modules and libraries.

How did you interpret what I said to mean that you would need to migrate all libraries and modules to the same FlexSim version??

0 Likes 0 ·
Alessio Merlo avatar image Alessio Merlo Phil BoBo ♦♦ commented ·
Thanks Phil!

I will test your idea, it should work! I need to create two different models and use FlexSim version selector to open it. Great!

One doubt for the future: when I will migrate both modules and libraries to same FlexSim version (not mandatory now), how I can manage it? Potentially the modules and libraries can be not compatible and then I will have 2 different flexsim.exe for the same version. In this case the selector recognizes just one, is it correct?

As for me will be mandatory to make the modules compatible!

0 Likes 0 ·
Show more comments