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

Adding a new interface does not automaticly connect to it #42

Open
mStirner opened this issue Jan 25, 2024 · 0 comments
Open

Adding a new interface does not automaticly connect to it #42

mStirner opened this issue Jan 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mStirner
Copy link
Member

mStirner commented Jan 25, 2024

When a new interface is added to a device, its not automatically bridged:

[2024.01.25 - 12:15.05.879][debug][system] Device in backend updated {
  _id: '65b23fe8fce293386bff6a34',
  name: 'Dummy Device',
  timestamps: { created: 1706180584953, updated: 1706181305867 },
  labels: [],
  room: null,
  enabled: true,
  interfaces: [
    {
      _id: '6581c55abc21a0a3122b9998',
      type: 'ETHERNET',
      description: 'WebSocket API',
      settings: [Object],
      adapter: [Array]
    }
  ],
  icon: null
}
[2024.01.25 - 12:15.05.881][debug][system] iface 6581c55abc21a0a3122b9998 updated, wait 1.5s

Because:

connector/handler.js

Lines 100 to 131 in 9727a3e

} else if (msg.event === "update") {
logger.debug(`iface ${iface._id} updated, wait 1.5s`);
// get worker instance from mapping
// send "shutdown" message to it
// listen for the exit event with code 0
// respawn worker
let worker = MAPPINGS.get(url2.toString());
if (!worker) {
return;
}
worker.once("exit", (code) => {
if (code === 0) {
setTimeout(() => {
// bridge updated device again
spawn(url2.toString(), iface.settings);
}, 1500);
}
});
// tell the worker to disconnect from ws endpoint
worker.postMessage("disconnect");
} else if (msg.event === "remove") {

When the device had no interface, and one was later added, there exists not worker for the interface. There fore a update of the device (what its done when a interface is added) does no recreate the worker, because there was no worker previously.

@mStirner mStirner added the bug Something isn't working label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant