Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CC3K can't connect to localhost/127.0.0.1 [or even own network IP address?!] #60

Open
natevw opened this issue Aug 4, 2014 · 6 comments

Comments

@natevw
Copy link
Contributor

natevw commented Aug 4, 2014

runtime/test/suite/net.js fails with this error:

server-basic

ok 107 ok
ok 108 ok
ok 109 ok
ok 110 ok
Error: ENOENT Cannot connect to 127.0.0.1 Got: err-1
stack traceback:
[T]:src/colony/modules/net.js:205: in function <[T]:src/colony/modules/net.js:209>

@natevw
Copy link
Contributor Author

natevw commented Aug 4, 2014

I don't really blame the CC3K for this one, as connections to that IP address are usually done through a separate loopback interface…but how should we handle this in both tests and any code that might rely on this? (Note the situation isn't unheard of, IIRC Heroku doesn't route localhost either.)

@natevw
Copy link
Contributor Author

natevw commented Aug 4, 2014

Related-ish, though perhaps deserves it's own issue: "localhost" does not resolve on Tessel either.

@natevw
Copy link
Contributor Author

natevw commented Aug 4, 2014

Hmmm, also related-ish, the CC3K doesn't seem to be able to connect to itself at all, perhaps. Noticed this while trying to test tessel/t1-runtime#336 with this script, modified to hardcode the IP address reported by tessel wifi -l:

var net = require('net');

var server = net.createServer(function (c) {
   console.log("connection");
   c.on('end', function () {
    console.log("connection end");
  });
  c.end("«§»");
});
server.listen(0, function () {
  console.log("listening");
  testConnection(server.address().port);
});

function testConnection(port) {
  console.log("testConnection", port);
//return;
  var client = net.connect(port, "192.168.4.122").on('data', function (d) {
    console.log(d.toString());
    setTimeout(function () {
      console.log("*** CLOSE ***");
      server.close();
      //client.end();
    }, 2e3);
  });
}

This basically hangs after the "testConnection" log, the on-Tessel client doesn't connect (IIRC eventually times out with an error UPDATE: nope) although I can telnet to the server from my laptop as expected.

@natevw natevw changed the title CC3K can't connect to localhost/127.0.0.1 CC3K can't connect to localhost/127.0.0.1 [or even own network IP address?!] Aug 4, 2014
@natevw
Copy link
Contributor Author

natevw commented Aug 4, 2014

At a broader level, there's already at least one other network interface that would like to play on Tessel: https://forums.tessel.io/t/tcp-commands-with-gprs-chip-not-working-as-expected-another-node-stream-issue/287/2

Maybe this is a situation (much like 'fs' module vs sdcard filesystems) where the firmware "kernel" itself needs to play better at routing calls?

@johnnyman727
Copy link
Contributor

@natevw, loopbacks aren't implemented in hardware. How does Heroku handle this?

@natevw
Copy link
Contributor Author

natevw commented Aug 12, 2014

That's what I mean, on Tessel we don't support multiple "drivers" and so adding one for a software loopback interface (or a cell module) doesn't fit the current architecture.

It's been a while and I didn't probe deeply with Heroku, just IIRC I couldn't make a connection to my own server from itself. This "making a client connection to own server" is the reason I noticed it, since that's what some of the 'net' module tests do — in practice it's probably not a showstopper for many "real" use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants