webContents.send And ipcRenderer.on


I am making an electron application and I am trying to use ipcRenderer to communicate between my window.html file to my main.js script, the problem is that the HTML file doesn’t get the message I am sending using webContents.send.

this is my main.js script:
mainWindow.webContents.send("command:message" , whatToLog);

this is my window.html script:

ipcRenderer.on('command:message', function(e, whatToLog) { console.log(whatToLog); });

the problem is that it doesn’t get the message, any help?


you must sure that
ipcRender.on is set before webContents.send()


The ipcRenderer is set before that.


can you put all of ur code here, or maybe try something like change channel name