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

Configurable Default Electron Port #504

Closed
aarong-av opened this issue Nov 11, 2020 · 10 comments
Closed

Configurable Default Electron Port #504

aarong-av opened this issue Nov 11, 2020 · 10 comments
Assignees
Labels
Milestone

Comments

@aarong-av
Copy link
Contributor

In many environments developers are not permitted to find available port. We must use specified ports allotted. Can we change the main.js file to include the following (~ line 66):

    let defaultElectronPort = 8000;
    if (manifestJsonFile.electronPort) {
        defaultElectronPort = (manifestJsonFile.aspCoreBackendPort)
    } 
    // hostname needs to belocalhost, otherwise Windows Firewall will be triggered.
    portscanner.findAPortNotInUse(defaultElectronPort, 65535, 'localhost', function (error, port) {
        console.log('Electron Socket IO Port: ' + port);
        startSocketApiBridge(port);
    });

This will allow users to explicitly set the port just as you can do with the aspNetCore port.

@GregorBiswanger
Copy link
Member

You need an additional configuration in the electron.manifest.json file with the key aspCoreBackendPort:

{
  "executable": "ElectronNET.WebApp",
  "splashscreen": {
    "imageFile": "/wwwroot/assets/img/about@2x.png"
  },
  "singleInstance": false,
  "aspCoreBackendPort": 8080, <--- Your custom Port for ASP.NET Backend
  "build": {
    "appId": "com.electronnetapidemos.app",
...

The application then runs automatically as a single instance. I hope you like it that way.

@aarong-av
Copy link
Contributor Author

I have the aspCoreBackendPort accounted for. I need the electronPort changed from its default of 8000 and then searching for whatever is available if 8000 is taken.

Ultimately I need the electron port to behave exactly like what was already done with aspCoreBackendPort.

Thanks for the quick reply!

@GregorBiswanger GregorBiswanger added this to the 10.5.1 milestone Nov 11, 2020
@aarong-av
Copy link
Contributor Author

Thanks for putting it on a milestone. I have a local branch. I don’t think I have permission to push.

Are there any other steps to implementing this other than what I have above?

Also how can I workaround this for now?

@GregorBiswanger
Copy link
Member

In this video I show, how you can work with the repository:
https://youtu.be/Po-saU_Z6Ws

Your pull request is very welcome to us :)

@aarong-av
Copy link
Contributor Author

I put in the PR. Let me know if it is wrong.

@skarin
Copy link

skarin commented Nov 11, 2020

I'd love to see this get In ASAP. Low risk, big impact. Thanks guys!

@GregorBiswanger
Copy link
Member

GregorBiswanger commented Nov 11, 2020

@skarin At the moment I'm still a bit busy - I don't think I'll have time for Electron until December - but a lot will happen that really rocks!

@aarong-av
Copy link
Contributor Author

Is there some guidance on the electron.manifest.json “files” section? I think I can work around this problem by making my own main.js but I can’t find any docs on how it works and copying an example ElectronHostHook does seem to overwrite the main.js.

@nazar322
Copy link

nazar322 commented Apr 16, 2024

So is there a way to set a default electron port in 23.6.1?

@nazar322
Copy link

"electronPort": 7777
Electron.NET needs a wiki on electron.manifest.json

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

No branches or pull requests

4 participants