Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port issue #31

Open
ajayashuba opened this issue Feb 6, 2019 · 2 comments
Open

port issue #31

ajayashuba opened this issue Feb 6, 2019 · 2 comments

Comments

@ajayashuba
Copy link

how do i make sure the port is not used by any other instance if i choose port by myself there is some % chance that that port might be in use ..is there way to programatically access the free port given by the system

@dev-ankur
Copy link

dev-ankur commented Sep 1, 2019

@ajayashuba Its been months, have you got any solution? I really need to know! I'm using ionic 4

@oddmario
Copy link

For all the recent and future readers, you can use https://github.com/doppiaQ/cordova-plugin-portfinder

Then start the webserver like that:

portfinder.getPort().then((port) => {
    webserver.start(
          function() {
            console.log("Started the HTTP server on port ", port);
          },
          function() {
            console.log('Failed to start the HTTP server');
          },
          port
    )
}).catch((e) => {
    console.log("Failed to find a free port");
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants