Initializing after restart

  • Hi,
    I would like to reinitialize RemoteObject after my app running in the engine has been restarted. For some reason sending image fails if app is restarted.

    Here's how to reproduce:

    1. Start testapp at the http://localhost:2015/
    2. Start test.js (see below)
    3. Success.
    4. Stop testapp after few seconds
    5. Start testapp after few seconds
    6. Failed.
    async function test() {
        try {
            const va = typeof window === "object" ?
            VisionAppster :           // Browser
            require("visionappster"); // Node.js
            const inputs = [
            await va.Image.fromUrl('image.jpg')
            const ctrl = new va.RemoteObject("http://localhost:2015/apis/com.myapps.testapp/1");
            const api = await ctrl.connect();
            await api.sendImage.async(...inputs);
        catch {
    setInterval(test, 2000);

    node.js v12.18.3
    npm visionappster 0.0.10
    VisionAppster 3.0-beta4.1

  • Hi,
    you can use manager object's appStarted signal to reconnect the API when the app has been restarted:

    const myAppId = 'com.myapps.testapp/1';
    let apiCtrl;
    let api;
    let managerCtrl;
    let manager;
    async function connectApi()
      if (apiCtrl)
        apiCtrl.disconnect(); // Note: this is currently needed first
      apiCtrl = new va.RemoteObject('/apis/' + myAppId);
      api = await apiCtrl.connect();
    async function connect()
      managerCtrl = new va.RemoteObject('/manager');
      manager = await managerCtrl.connect();
      manager.$appStarted.connect((appId) =>
        if (appId === myAppId)

    Now, if you add connect() call before setInterval() call in your example, the api object should be always connected and ready to serve whenever the app is running.
    P.S. there seems to be also an issue that the previous remote api object instance needs to be disconnected first, or reconnecting won't work. We'll be looking at
    that also.

  • @mt Thanks.

Log in to reply