hk7
hk7

Reputation: 53

Chrome Extension port.onDisconnect listener for native connection is not getting called when the native app shuts down

In my chrome extension code I am establishing a native connection to a native app and now whenever that native app shuts down, the chrome extensions port.onDisconnect listener is not getting fired.

Can anyone please help me on how to achieve this.

port = chrome.runtime.connectNative("host.name");

port.onMessage.addListener(function(data) {});

// Not getting fired when native app shuts down
port.onDisconnect.addListener(function(event) {});

Upvotes: 2

Views: 4770

Answers (1)

Lennart
Lennart

Reputation: 151

Did you setup the native application host as described in the documentation?

Apart from that, you can try to force the port to disconnect by invoking port.disconnect(). Maybe the port doesn't necessarily disconnect when the native application shuts down.

Upvotes: 1

Related Questions