amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.07k stars 1.16k forks source link

Trouble connecting to Gun when server is spun up inside of Electron #815

Closed mboperator closed 5 years ago

mboperator commented 5 years ago

Context

I'm building a decentralized story telling desktop application using Electron. The Electron app is comprised of a server and a client.

The client is a React app. The server is a node server running Express with Gun middleware.

Package Versions

"express": "~4.16.1"
"gun": "^0.2019.726"
"electron": "4.0.8"
"node": "12.10.0"

The Problem

When running the server outside of Electron in dev mode, everything works fine:

Screen Shot 2019-09-14 at 10 54 42 AM

My Electron app is unable to hit the Gun websocket endpoint when the server is run from within Electron:

Screen Shot 2019-09-14 at 1 45 02 PM

The server is able to start properly inside of Electron. http://localhost:7000 shows my hello world page.

Relevant Code Snippet

This is the Electron server:

Screen Shot 2019-09-14 at 1 42 31 PM

This is how I'm spinning up my express server inside of Electron:

Screen Shot 2019-09-14 at 1 41 32 PM

Things I've Tried:

If anyone has any example of an Express server running Gun inside of Electron that would be a huge help.

Thanks in advanced!

mboperator commented 5 years ago

Fixed my own issue. The return value of server.listen needs to be passed into the Gun constructor.

Screen Shot 2019-09-14 at 2 32 07 PM
amark commented 5 years ago

Sorry about that! Glad you got it working.