Giter Site home page Giter Site logo

Comments (4)

BarryCarlyon avatar BarryCarlyon commented on July 17, 2024

I tried something nutty like

function connectToSim() {
    simConnect = '';

    for (var k in require.cache) {
        if (k.indexOf('node-simconnect') >= 0) {
            if (k.indexOf('index.js') >= 0) {
                console.log('uncache', k);
                delete require.cache[k];
            }
        }
    }
    simConnect = require('node-simconnect');

But it doesn't seem to help. (dump cache and refresh)

So it's damn weird

from node-simconnect.

BarryCarlyon avatar BarryCarlyon commented on July 17, 2024

In some testing, it doesn't seem to affect the refactor branch. (running outside of electron)
But does the main branch (also outside of electron)

But it's stated we shouldn't use it (refactor) in "production" yet, so I'm hesitant to switch over for my app/usage.

Additionally under main, a setInterval'ed call to

    simConnect.requestDataOnSimObjectType(navInfoDefIdOthers, function(data) {

Is yielding no data/planes returned. So it's not just the open callback that is failing. (standard 10km range, and I'm parked at EGLL/Heathrow, so there's always 100 odd planes in sim)

Edit: Random side thought, I think under MSFS 1.12.13.0 they actually fixed is so on normal close, NodeSimconnect reads a proper quit (well a quit and an error). (And it's probable the error comes from my setInterval'ed call to requestDataOnSimObjectType

And the issue is in the quit/cleanup logic. As prior to 1.12.13.0 I recall we would just get a sincommect error instead of a nice quit.

from node-simconnect.

BarryCarlyon avatar BarryCarlyon commented on July 17, 2024

It seems that modify all "reconnect" to have an explicit close before hand resolves the problem I have observed

So

https://github.com/EvenAR/node-simconnect/blob/master/examples/nodejs/example.js#L5

Becomes

function connectToSim() {
    console.log("Trying to connect...")

    var success = simConnect.open("MyAppName", function(name, version) {
        console.log("\n-----------------------------------------------\nConnected to: " + name + "\nSimConnect version: " + version + "\n-----------------------------------------------");
        doStuffWithSimconnect();

    }, () => {
        console.log("Quit.... :(");
        simConnect.close();
        setTimeout(() => {
            connectToSim();
        }, 5000);
    }, (exception) => {
        console.log("SimConnect exception: " + exception.name + " (" + exception.dwException + ", " + exception.dwSendID + ", " + exception.dwIndex + ", " + exception.cbData + ")");
    }, (error) => {
        // Happens for example when connection with SimConnect is lost unexpectedly. For crash details: ntstatus.h
        console.log("SimConnect error: " + error);

        // The connection must be re-opened
        simConnect.close();
        setTimeout(() => {
            connectToSim();
        }, 5000);
    });

    if(!success) {
        simConnect.close();
        setTimeout(() => {
            connectToSim();
        }, 5000);
    }
}

Instead.

It's proving more reliable in the

  • start app
  • open sim
  • app connects
  • close sim (safe quit as apposed to CTD)
  • open sim
  • app reconnects properly (calls open callback etc) (yay)

scenario

The explicit call to .close() seems to tidy out whatever "normal quit" buffer/garbage that doesn't get cleaned up.

from node-simconnect.

EvenAR avatar EvenAR commented on July 17, 2024

I understand a workaround was found for the old version and that v3.x handles this better.

from node-simconnect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.