Configurable Default Electron Port #589

Closed
opened 2026-01-29 16:43:32 +00:00 by claunia · 10 comments
Owner

Originally created by @aarong-av on GitHub (Nov 11, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

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.

Originally created by @aarong-av on GitHub (Nov 11, 2020). Originally assigned to: @GregorBiswanger on GitHub. 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.
claunia added the Feature label 2026-01-29 16:43:32 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (Nov 11, 2020):

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.

@GregorBiswanger commented on GitHub (Nov 11, 2020): 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.
Author
Owner

@aarong-av commented on GitHub (Nov 11, 2020):

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!

@aarong-av commented on GitHub (Nov 11, 2020): 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!
Author
Owner

@aarong-av commented on GitHub (Nov 11, 2020):

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?

@aarong-av commented on GitHub (Nov 11, 2020): 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?
Author
Owner

@GregorBiswanger commented on GitHub (Nov 11, 2020):

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 :)

@GregorBiswanger commented on GitHub (Nov 11, 2020): 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 :)
Author
Owner

@aarong-av commented on GitHub (Nov 11, 2020):

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

@aarong-av commented on GitHub (Nov 11, 2020): I put in the PR. Let me know if it is wrong.
Author
Owner

@skarin commented on GitHub (Nov 11, 2020):

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

@skarin commented on GitHub (Nov 11, 2020): I'd love to see this get In ASAP. Low risk, big impact. Thanks guys!
Author
Owner

@GregorBiswanger commented on GitHub (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!

@GregorBiswanger commented on GitHub (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!
Author
Owner

@aarong-av commented on GitHub (Nov 11, 2020):

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.

@aarong-av commented on GitHub (Nov 11, 2020): 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.
Author
Owner

@nazar322 commented on GitHub (Apr 16, 2024):

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

@nazar322 commented on GitHub (Apr 16, 2024): So is there a way to set a default electron port in 23.6.1?
Author
Owner

@nazar322 commented on GitHub (Apr 16, 2024):

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

@nazar322 commented on GitHub (Apr 16, 2024): `"electronPort": 7777` Electron.NET needs a wiki on `electron.manifest.json`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#589