electrify icon indicating copy to clipboard operation
electrify copied to clipboard

Electron won't start until network is on

Open MendelYev opened this issue 9 years ago • 11 comments

I started with a fresh node-meteor-electrify installation on WIndows 8, and did an "electrify package" on the exemple app that a "meteor create" gives. Everything works fine when wifi or ethernet connexion is available. But if my network is off, nothing happens when I click on the .exe (the Electron process is running but nothing shows up). Then if I establish a network connection, the app finally launches proprerly.

Is there a way to create a complete offline app with electrify ? I tried with a Meteor.disconnect() on Meteor.startup but didn't work either.

MendelYev avatar Dec 05 '15 15:12 MendelYev

Hi @MendelYev, thanks for reporting.

It should work completely offline as well, since everything is running locally.

I'll take a look at it later.

arboleya avatar Dec 05 '15 17:12 arboleya

Thanks for analyzing this. I just tried on a Windows 7 64bits and encoutered the same problem (it waits for wifi or ethernet to start).

MendelYev avatar Dec 06 '15 19:12 MendelYev

I can't reproduce it here, perhaps it can be something with windows firewall on your end?

arboleya avatar Dec 08 '15 20:12 arboleya

Maybe your app is trying to download some js scripts from the internet?

netsuileo avatar Feb 10 '16 05:02 netsuileo

Сheck your head.html in resources\app\app\programs\web.browser directory. If it has some code like the following <script src="https://code.angularjs.org/1.3.0-rc.2/i18n/angular-locale_ru-ru.js"></script> the window will not launch unless internet connection is available. All files for the project should be in bundle.

AlexDel avatar Feb 10 '16 05:02 AlexDel

Update: This turned out to be the fundemental problem with communication between node and mongo. They speaks through tcp sockets, When network is down windows disables tcp socket and node and mongo can't connect even on localhots. Maybe this will be fixed in Meteor1.4 where node4 will be used instead of 0.10

#https://github.com/atom/electron/issues/2299

AlexDel avatar Feb 10 '16 14:02 AlexDel

@AlexDel Good catch!

So I assume that meteor itself doesn't work when network is down on Windows?

arboleya avatar Feb 12 '16 18:02 arboleya

This might be helpful to some: I'm developing a desktop app that needs offline capabilities. The workaround for this problem is a bit extensive but works 100%. The solution is with installing the microsoft loopback device. This provides a network interface even when there are no other devices available.

You'll probably need to do some research for your exact needs, but this works and should give the path to a possible solution.

1) First check if the loopback device exists with the npm network package

network.get_interfaces_list(function(err, list){
    var loopbackFound = false;

    list.forEach(function(obj){
        if(obj.model.indexOf("Microsoft") > -1 && obj.model.indexOf("Loopback") > -1){
            loopbackFound = true;
        }
    });
}

2) Package 2 executables with the app: nircmd and devcon64. nircmd to easily run a command as admin, devcon to actually install the loopback device (you'll need to adjust the path to these exe's depending on where you put them)

var execCmd = '"'+path.join(currentDirectory, 'resources', 'app', 'nircmd.exe')+'" elevate "'+path.join(currentDirectory, 'resources', 'app', 'devcon64.exe')+'" install %windir%/inf/netloop.inf *msloop';

var exec = require("child_process").exec;
exec(execCmd, function(error, stdout, stderr){
    if(error){
        console.error(`exec error: ${error}`);
        return;
    }
    console.log(`stdout: ${stdout}`);
    console.log(`stderr: ${stderr}`);
});

Once installed (takes only a few seconds max) the app starts up normally and this issue shouldn't occur anymore.

nicklammertyn avatar Jun 12 '16 00:06 nicklammertyn

Hi guys,

I'm also having trouble regarding with this. When i turn offline and run the electron app it won't start. Even the Electron API Demo.

Joy

joyfementira avatar Oct 11 '16 18:10 joyfementira

When 127.0.0.1 is used instead of localhost for connecting the services it works even without an active network connection. I changed this in a fork I created.

Mairu avatar Jul 31 '17 13:07 Mairu

@Mairu

When 127.0.0.1 is used instead of localhost for connecting the services it works even without an active network connection.

Indeed, I opened Atom and changed all the instances of "localhost" TO "127.0.0.1" and it worked ! and I'm using this version, even if its outdated it has worked for me.

Thank you for you suggestion @Mairu

AthmaneKhl avatar Dec 11 '17 20:12 AthmaneKhl