Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Gary_B_1
Beginner
49 Views

basic server problem (XDK and Intel Edison)

Jump to solution

I'm not sure if the problem is related to XDK or the Edison.

If I use XDK/Edison combination to create a very simple server that listens on port 3000,  I get the "Server Listening on port 3000" message on the XDK console, but openning up a web browser to   localhost:3000 doesn't trigger the call back so I never see "Hello World".  

  1. var http = require("http");
  2. var server = http.createServer(function(req, res) {
  3.     res.writeHead(200, {"Content-Type": "text/html"});
  4.     res.end("Hello World");
  5. });
  6. server.listen(3000);
  7. console.log("Server listening on port 3000");

If I do the same thing on my Ubuntu host at a nodejs console,  it works as expected:

- See the Listening on Port 3000 message

- open a Chrome browser tab to  localhost:3000

- this yields the  "Hello World" Message.

Again, I don't know if it's related to the Edison or XDK so I figured I would run it by the experts  ( that's you :c).

I can run basic node.js demos that use the console but seems like anything related to the network server,  does not work.

I assum the version of XDK is  3522 ?  (xdk_web_linux64_master_3522.tgz)

- Thanks in Advance

 

 

 

Tags (2)
0 Kudos

Accepted Solutions
PaulF_IntelCorp
Employee
49 Views

When you do this experiment on your Ubuntu machine your server and client are on the same machine, that is why the browser talking to localhost works in that environment, because the "server" named "localhost" which is running your Node.js server code is present. However, when you do that on the Edison your browser is not running on the Edison. "localhost" always means the machine on which the app is running, but the browser is not running on your Edison, where your Node.js server code is running. You need to substituted the IP address of your Edison board instead of "localhost" in your browser URL. The XDK does not redirect anything from your development system to the Edison, it's just a convenient tool for getting code onto your Edison and for seeing debug output from the Edison, nothing more.

BTW -- the editor inside the XDK is just the Brackets editor. You can also download and run it standalone.

View solution in original post

0 Kudos
3 Replies
Gary_B_1
Beginner
49 Views

As a quick note,  the reason I am using XDK and the Edison,  rather than running the basic demos directly on my host, is because I like the Intel Editor and it's node.js awareness.        

I've gotten into the happen of creating the basic demo using XDK but then run the runs on my host.  However,  I would be interested in getting it to work with the Edison Board just for the sake of learning more about the board and tools.

 

0 Kudos
PaulF_IntelCorp
Employee
50 Views

When you do this experiment on your Ubuntu machine your server and client are on the same machine, that is why the browser talking to localhost works in that environment, because the "server" named "localhost" which is running your Node.js server code is present. However, when you do that on the Edison your browser is not running on the Edison. "localhost" always means the machine on which the app is running, but the browser is not running on your Edison, where your Node.js server code is running. You need to substituted the IP address of your Edison board instead of "localhost" in your browser URL. The XDK does not redirect anything from your development system to the Edison, it's just a convenient tool for getting code onto your Edison and for seeing debug output from the Edison, nothing more.

BTW -- the editor inside the XDK is just the Brackets editor. You can also download and run it standalone.

View solution in original post

0 Kudos
Gary_B_1
Beginner
49 Views

Hey Paul,

That was it ...    I don't believe I missed that.

Thanks,
GB

0 Kudos