Native messaging api disconnected port error

I have an extension which i am trying to send a message to a program with it.I am using the same example as on the native-messaging documentation.I define the port but when i call ‘port.postMessage(“ping”)’ it says : “Error: Attempt to postMessage on disconnected port.”.I added the “ping_pong” in the HKEY_LOCAL_MACHİNE and HKEY_CURRENT_USER and wrote the path to “ping_pong.json” i couldnt find any solutions.Can anyone help me ?
Thanks…

Please upload your extension and the Python file.
(When you reply, click on the “Upload” icon)

This is ping_pong.py file :


This is background.js file :
background javascript
This is manifest.json of extension :
manifest file

I solved it.My solution was changing the “name” property in the native application’s manifest file and in the registry.Here is the pictures of them.

ping_pongjson

I think the problem was using the same name in the documentary “ping_pong”.Because my other extensions use native-messaging api and they work really fine.

EDİT = İf this didnt work try following steps :
1)Check your “ping_pong_win.bat” file and try putting quotes ("") to your path for example :

@echo off
call python “C:\\Users\\your username\\Desktop\\nativeapp\\app\\ping_pong.py”

Copy and write this to your “ping_pong_win.bat” file without this ( ’ )
2)Check your HKLM\SOFTWARE\Mozilla\NativeMessagingHosts\ping_pong and HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ping_pong
“ping_pong” should be same with your native app’s manifest file’s “name” value in my case it is “deneme”.
3) Check the two registry i said in “2)” their keys should be pointing to native app’s manifest.json file for example :


4)Your add-on’s id should match your native app’s “allowed-extensions” attribute for example :
This is native app’s “allowed_extensions” part from its “manifest.json” file

This is add-on’s id from its “manifest.json” file
5

After changing them i simply did what the documentary said.I wrote :
"
var port = browser.runtime.connectNative(“deneme”);
port.onMessage.addListener((message)=>{
console.log("Response is : " + message);
});
try{
port.postMessage(“what ever you want”);
}catch(error1){
console.error("Error : " + error1.message);
}
"

I hope this helps anybody who is having this trouble.