Is it possible to integrate express server into node-webkit app?

11 views
Skip to first unread message

vict...@gmail.com

unread,
Apr 27, 2014, 10:31:20 AM4/27/14
to node-...@googlegroups.com
I've meet a need to implement this remote debug scene:
[Debugger (node-webkit)] -- [Communicate Server (like a chatting room)] -- [Debuggee (Mobile App)]
  1. The Debugger and Communicate Server should be a single .exe on PC.
  2. The Debugger call RESTful API of Communicate Server, which redirected to Debuggee (Mobile App) by socket.io.
  3. Why I choose RESTful API on Debugger side is I need debugger thread to be blocked until the Debuggee side execution returns.
Though according to about node.js server side script in node webkit, it's not recommend to setup an express server in node-webkit, but I need to setup a express in order to provide some "blocking" restful services. These are what I've done:

Use node-webkit to load a local.html.
  1. In local.html, use "require()" to start an express server.
  2. If I use ajax to request RESTful service http://localhost/xxx from local file, I'll meet Cross-Domain problem.
  3. If I use window.location =, the page reloads, and the express server will stop.
So I'm stuck on Step 2. or 3.. Is there any way to achieve this?

Laszlo Z. Antal

unread,
Apr 27, 2014, 4:15:53 PM4/27/14
to node-...@googlegroups.com
Hi,
Haven't tried it but it might work: use local IP address instead of local host, and run express on a port other than 80. Then in your nw app use child process to start the express server so it runs outside of nw. 

Laszlo

--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Victor.Woo

unread,
Apr 28, 2014, 5:12:58 AM4/28/14
to node-...@googlegroups.com
Hi,

On Mon, Apr 28, 2014 at 4:15 AM, Laszlo Z. Antal <lza...@gmail.com> wrote:
Hi,

On Apr 27, 2014, at 7:31, vict...@gmail.com wrote:

I've meet a need to implement this remote debug scene:
[Debugger (node-webkit)] -- [Communicate Server (like a chatting room)] -- [Debuggee (Mobile App)]
  1. The Debugger and Communicate Server should be a single .exe on PC.
  2. The Debugger call RESTful API of Communicate Server, which redirected to Debuggee (Mobile App) by socket.io.
  3. Why I choose RESTful API on Debugger side is I need debugger thread to be blocked until the Debuggee side execution returns.
Though according to about node.js server side script in node webkit, it's not recommend to setup an express server in node-webkit, but I need to setup a express in order to provide some "blocking" restful services. These are what I've done:

Use node-webkit to load a local.html.
  1. In local.html, use "require()" to start an express server.
  2. If I use ajax to request RESTful service http://localhost/xxx from local file, I'll meet Cross-Domain problem.
  3. If I use window.location =, the page reloads, and the express server will stop.
So I'm stuck on Step 2. or 3.. Is there any way to achieve this?

Haven't tried it but it might work: use local IP address instead of local host, and run express on a port other than 80. Then in your nw app use child process to start the express server so it runs outside of nw. 
Which technology should I use to create child process?
If I use local IP address, such as "127.0.0.1", the ajax request from local page inside nw should meet "Cross Domain XHR" problem :(
 

Laszlo

--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "node-webkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-webkit/g2iVPNSetSM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-webkit...@googlegroups.com.

Laszlo Z. Antal

unread,
Apr 28, 2014, 10:16:57 AM4/28/14
to node-...@googlegroups.com
Hi,

On Apr 28, 2014, at 2:12, "Victor.Woo" <vict...@gmail.com> wrote:

Hi,

On Mon, Apr 28, 2014 at 4:15 AM, Laszlo Z. Antal <lza...@gmail.com> wrote:
Hi,

On Apr 27, 2014, at 7:31, vict...@gmail.com wrote:

I've meet a need to implement this remote debug scene:
[Debugger (node-webkit)] -- [Communicate Server (like a chatting room)] -- [Debuggee (Mobile App)]
  1. The Debugger and Communicate Server should be a single .exe on PC.
  2. The Debugger call RESTful API of Communicate Server, which redirected to Debuggee (Mobile App) by socket.io.
  3. Why I choose RESTful API on Debugger side is I need debugger thread to be blocked until the Debuggee side execution returns.
Though according to about node.js server side script in node webkit, it's not recommend to setup an express server in node-webkit, but I need to setup a express in order to provide some "blocking" restful services. These are what I've done:

Use node-webkit to load a local.html.
  1. In local.html, use "require()" to start an express server.
  2. If I use ajax to request RESTful service http://localhost/xxx from local file, I'll meet Cross-Domain problem.
  3. If I use window.location =, the page reloads, and the express server will stop.
So I'm stuck on Step 2. or 3.. Is there any way to achieve this?

Haven't tried it but it might work: use local IP address instead of local host, and run express on a port other than 80. Then in your nw app use child process to start the express server so it runs outside of nw. 
Which technology should I use to create child process?


If I use local IP address, such as "127.0.0.1", the ajax request from local page inside nw should meet "Cross Domain XHR" problem :(

Have you tried it? When I was using nw for apps(0.8x) it never complained to me about cross domain. 
Also instead of using localhost IP you could grab the computer's actual IP. 

Hope it helps

Laszlo
Reply all
Reply to author
Forward
0 new messages