saltyshiomix / nextron

⚡ Next.js + Electron ⚡
https://npm.im/nextron
MIT License
3.69k stars 215 forks source link

Not Working IPC #413

Closed Rostov4an1n closed 8 months ago

Rostov4an1n commented 9 months ago

Tell me how you can fix the problem. I created a custom top panel where the close, collapse, expand buttons are located. I want to use the example of the close button to send an IPC, which will close the application when pressed.

But when I tried to download the IPC-communication application template, I was faced with the fact that it does not work.

Can you tell me how to send IPC signals? If you would provide an example of a solution to my problem, then I would be very grateful to you

Rostov4an1n commented 9 months ago

I saw a Roadmap for future updates of this project, where everything will be fixed. Could you tell me when to expect a future update?

abrarabedin001 commented 9 months ago

My team and I are also facing the same issue. It would be helpful if we could see a working project

makeusabrew commented 8 months ago

Check out the official Electron examples on IPC communication, specifically this section on communication from the renderer to the main process: https://www.electronjs.org/docs/latest/tutorial/ipc#pattern-2-renderer-to-main-two-way

Here's the code for it: https://github.com/electron/electron/tree/v27.0.0/docs/fiddles/ipc/pattern-2

That example isn't identical, but it's close: you just need to swap out the logic in the main process where the example opens a native file dialog and instead call app.quit(). The principles are identical though.

Happy to help debug any code either of you have got which isn't working once you get close.

abrarabedin001 commented 8 months ago

image

I am importing electron as shown in the example . But I am getting the following error

image

abrarabedin001 commented 8 months ago

here is my background.ts

import { app, ipcMain } from 'electron'
import serve from 'electron-serve'
import { createWindow } from './helpers'

const isProd: boolean = process.env.NODE_ENV === 'production'

if (isProd) {
  serve({ directory: 'app' })
} else {
  app.setPath('userData', `${app.getPath('userData')} (development)`)
}

; (async () => {
  await app.whenReady()

  const mainWindow = createWindow('main', {
    width: 1000,
    height: 600,
    minWidth: 960,
    minHeight: 600,
  })

  if (isProd) {
    await mainWindow.loadURL('app://./home')
  } else {
    const port = process.argv[2]
    await mainWindow.loadURL(`http://localhost:${port}/home`)
    // mainWindow.webContents.openDevTools()
  }
})()

app.on('window-all-closed', () => {
  app.quit()
})

ipcMain.on('ping-pong', (event, arg) => {
  event.sender.send('ping-pong', `[ipcMain] "${arg}" received asynchronously.`)
})
pixkk commented 8 months ago

Maybe https://github.com/saltyshiomix/nextron/issues/396#issuecomment-1756059475 can help. Try change renderer settings

Rostov4an1n commented 8 months ago

image

I am importing electron as shown in the example . But I am getting the following error

image

Greetings. I have the same problem. The developer of this repository said that he will fix IPC-Communication in the next update

saltyshiomix commented 8 months ago

I'll fix the bug soon, sorry for inconvenience 🙇

saltyshiomix commented 8 months ago

@Rostov4an1n CC: @abrarabedin001 @pixkk

Nextron v8.12.0 is out! Now it supports preload script for secure IPC features :)

If you have time, please try new examples:

npx create-nextron-app test-app --example basic-lang-typescript
abrarabedin001 commented 8 months ago

thanks for letting us know. Will check it out soon.

Rostov4an1n commented 8 months ago

@saltyshiomix Thank you very much for the work done! I was able to positively connect the functions of interaction with the buttons of the upper panel of the application via IPC Electron. If I knew how, I could attach a video video evidence 😁🎉

hfd666 commented 8 months ago

@Rostov4an1n CC: @abrarabedin001 @pixkk

Nextron v8.12.0 is out! Now it supports preload script for secure IPC features :)

If you have time, please try new examples:

npx create-nextron-app test-app --example basic-lang-typescript

download temp error~

PS E:\project\nextrons> npx create-nextron-app my-app --example basic-lang-typescript Need to install the following packages: create-nextron-app Ok to proceed? (y) y ✔ Validating existence...
⠇ Downloading and extracting...node:events:368 throw er; // Unhandled 'error' event ^

RequestError: connect ETIMEDOUT 20.205.243.165:443 at ClientRequest. (C:\Users\admin\AppData\Local\npm-cache_npx\b53a4342db57cff4\node_modules\got\dist\source\core\index.js:970:111) at Object.onceWrapper (node:events:510:26) at ClientRequest.emit (node:events:402:35) at ClientRequest.origin.emit (C:\Users\admin\AppData\Local\npm-cache_npx\b53a4342db57cff4\node_modules\@szmarczak\http-timer\dist\source\index.js:43:20) at TLSSocket.socketErrorListener (node:_http_client:447:9) at TLSSocket.emit (node:events:390:28) at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3) at processTicksAndRejections (node:internal/process/task_queues:83:21) at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) Emitted 'error' event on Request instance at: at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3) at processTicksAndRejections (node:internal/process/task_queues:83:21) { code: 'ETIMEDOUT', timings: { start: 1697426026936, socket: 1697426026936, lookup: 1697426026938, connect: undefined, secureConnect: undefined, upload: undefined, end: undefined, error: 1697426047978, abort: undefined, phases: { wait: 0, dns: 2, tcp: undefined, tls: undefined, request: undefined, firstByte: undefined, download: undefined, total: 21042 } } }

@Rostov4an1n CC: @abrarabedin001 @pixkk

Nextron v8.12.0 is out! Now it supports preload script for secure IPC features :)

If you have time, please try new examples:

npx create-nextron-app test-app --example basic-lang-typescript
pixkk commented 8 months ago

RequestError: connect ETIMEDOUT 20.205.243.165:443

Check your internet connection (or disable/enable VPN for downloading packets).

MuneebChaudhry-dev commented 1 week ago

The issue Still Persist , Nothing changed.

Here is the Error: image

The issue Occur after the import of "IpcRenderer" image

Here are my dependencies: image

@saltyshiomix Kindly look into this.. I have used the electron-react-boilerplate where they wrap the ipc into some kind of API or simple callback functions. Also doing some communication stuff useing electron-store. But I'm still unable to understand your method for communication. Can you please update some documentation at least for some basic things.