Git Product home page Git Product logo

electron-with-server-example's Issues

ENOENT when running on windows

after cloning, renaming to lightroom-catalog-helper, and running npm install, running npm start on Windows 10 x64 leads to the following error:

C:\Users\Pomax\Documents\Git\projects\lightroom-catalog-helper>npm start

> [email protected] start C:\Users\Pomax\Documents\Git\projects\lightroom-catalog-helper
> electron .


 checking 1
Service path not specified, so defaulting to ipc.config.socketRoot + ipc.config.appspace + id
requested connection to  myapp1 /tmp/app.myapp1
Connecting client on Unix Socket : /tmp/app.myapp1


######
error:  { Error: connect ENOENT \\.\pipe\tmp-app.myapp1
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1061:14)
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'connect',
  address: '\\\\.\\pipe\\tmp-app.myapp1' }
found socket 1
connection closed myapp1 /tmp/app.myapp1 Infinity tries remaining of Infinity
Yuki exceeded connection rety amount of  or stopRetrying flag set.

(Yuki being the machine name for this particular Win10 installation)

How do you secure the socket?

In theory any process on the machine could communicate with the socket right? How have you secured this with your app?

The renderer's node-ipc works in the {contextIsolation: true} ?

Electron 12 it will be enabled contextIsolation by default.
https://www.electronjs.org/docs/tutorial/context-isolation

contextBridge.exposeInMainWorld('electron', {
  getSocketId: () => socketPromise,
  ipcConnect: (id, func) => {
    ipc.config.silent = true
    ipc.connectTo(id, () => {
      func(ipc.of[id])
    })
  },
  ...
})

got error:
image

const connectSocket = (socketId: string) => {
  window.electron.ipcConnect(socketId, (client) => {
    client.on('message', (data: string) => {
      const msg = JSON.parse(data)
  ...

Sugesstion: Add a TL;DR section

First of all, thanks for the awesome example. It's really helpful.

Can a TL;DR section be added? It will be helpful for people who have already read through the entire readme file and can use it for quick reference\lookup

something like this:

File description
index.js The main renderer process
server-ipc.js IPC handler for the server

In 2023, how does it compares to native IPC from electron?

Hi,
It's 2023, and I'm reading electron docs about IPC. I'm in doubt how the ideas from this repo (and the blog related to it) compares to native implementation of electron IPC. Is it possible to implement these ideas using electron IPC? Is it still worth to do that ?
Thanks!
Ely

Just a heads up about the node-ipc package

Hi James,

I've used this repository and your articles about using IPC communication with electron with much success--they've been super helpful!

I just wanted to post a heads up about the node-ipc package: sadly the author sabotaged it in March of 2022 by adding malware aimed at machines with Russian IP addresses. see: malware article

I'll be looking for alternatives for node-ipc now.... If you have any recommendations I'd appreciate it!

Thanks,
Bill.

use cluster in server-ipc

Is it possible and recommended to use cluster in childprocess (ipc-server.js) to improve server performance with more than 1 cpu?
try the following implementation according to the ipc-node documentation:

`const ipc = require('node-ipc')
const fs = require('fs')
const cpuCount = require('os').cpus().length
const cluster = require('cluster')
const socketPath = '/tmp/ipc.sock'

function init(socketName, handlers) {
ipc.config.unlink = false
if (cluster.isMaster) {
if (fs.existsSync(socketPath)) {
fs.unlinkSync(socketPath)
}
for (let i = 0; i < cpuCount; i++) {
cluster.fork()
}
} else {

	ipc.serve(socketPath, () => {
		ipc.server.on('message', (data, socket) => {
			let msg = JSON.parse(data)
			let { id, name, args } = msg

			if (handlers[name]) {
				handlers[name](args).then(
					(result) => {
						ipc.server.emit(socket, 'message', JSON.stringify({ type: 'reply', id, result }))
					},
					(error) => {
						// Up to you how to handle errors, if you want to forward
						// them, etc
						ipc.server.emit(socket, 'message', JSON.stringify({ type: 'error', id }))
						throw error
					}
				)
			} else {
				console.warn('Unknown method: ' + name)
				ipc.server.emit(socket, 'message', JSON.stringify({ type: 'reply', id, result: null }))
			}
		})
	})

ipc.server.start()
console.log(`pid ${process.pid} listening on ${socketPath}`);
}

}

function send(name, args) {
ipc.server.broadcast('message', JSON.stringify({ type: 'push', name, args }))
}

module.exports = { init, send }`

But I get an error:
TypeError: handle.setSimultaneousAccepts is not a function at ChildProcess.target._send (internal/child_process.js:761:16) at ChildProcess.target.send (internal/child_process.js:676:19) at sendHelper (internal/cluster/utils.js:22:15) at send (internal/cluster/master.js:351:10) at internal/cluster/master.js:317:5 at SharedHandle.add (internal/cluster/shared_handle.js:29:3) at queryServer (internal/cluster/master.js:311:10) at Worker.onmessage (internal/cluster/master.js:246:5) at ChildProcess.onInternalMessage (internal/cluster/utils.js:43:8) at ChildProcess.emit (events.js:215:7)

Any help is welcome thanks.

Windows Server run C

Electron的server只能运行的C盘吗
我把app装在D盘 发现服务的运行目录在C盘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.