-
Notifications
You must be signed in to change notification settings - Fork 33
Description
To reproduce, setup a key and start a local proxy server with your "config/env" file contents as such:
PORT=5005
zzz_AUTH_TESSEL_OA2=http://tessel-proxy-dev:the-tessel-devenv@localhost:3002
AUTH_HARDCODED=DEV-CRED
Then run this script under colony built from the #702 branch (also, note relative path to proxy's public key):
process.env._PROXY_DBG = true;
//process.env.PROXY_HOST = "proxy.192.168.4.114.xip.io";
process.env.PROXY_HOST = "localhost";
process.env.PROXY_PORT = 5005;
process.env.PROXY_TOKEN = "DEV-CRED";
process.env.PROXY_CERT = require('fs').readFileSync("../proxy/config/public-cert.pem").toString();
process.env.PROXY_IDLE = 1e3;
var n = 0;
function makeRequest() {
console.log("Making request", ++n);
var req = require('http').request("http://dbg-"+n+".ipcalf.com/?format=text", function(res) {
console.log("req status:", res.statusCode);
res.on('data', function (d) {
console.log("req data:", d.toString());
});
res.on('end', function () {
console.log("req done.");
});
});
req.on('error', function (e) {
console.error("Problem with request:", e.stack);
});
req.end();
}
setInterval(makeRequest, 3e3);
setInterval(makeRequest, 100);
For me the following happens: the client keeps rolling along but soon doesn't get any responses back. If you look in the proxy logs, you'll see it thinks that the client has disconnected after only a few requests.
Now's where it gets interesting. Apply this one-line change locally and rebuild colony:
diff --git a/src/colony/modules/_net_proxied.js b/src/colony/modules/_net_proxied.js
index dec688f..278e223 100644
--- a/src/colony/modules/_net_proxied.js
+++ b/src/colony/modules/_net_proxied.js
@@ -38,7 +38,8 @@ var _PROXY_DBG = ('_PROXY_DBG' in process.env) || false,
function createTunnel(cb) {
if (_PROXY_DBG) console.log("TUNNEL -> START", new Date());
- tls.connect({host:PROXY_HOST, port:PROXY_PORT, proxy:false, ca:[PROXY_CERT]}, function () {
+ //tls.connect({host:PROXY_HOST, port:PROXY_PORT, proxy:false, ca:[PROXY_CERT]}, function () {
+ net.connect({host:PROXY_HOST, port:PROXY_PORT, proxy:false, ca:[PROXY_CERT]}, function () {
var proxySocket = this,
tunnel = streamplex(streamplex.B_SIDE);
tunnel.pipe(proxySocket).pipe(tunnel);
Do the same change in the proxy's "proxy.js" file (i.e. swap tls.createServer for net.createServer) — it should restart automatically if you've used npm start.
Now the tunnel connection will happen over plaintext socket for debugging — I originally did this so I could more easily see the pre-hangup tunnel data in Wireshark.
BUT now when you run the client test script, it now goes properly gangbusters with the requests/responses working for a long time (eventually my DNS server seems to get upset with all my requests, but still the system behaves otherwise ± as expected in the situation).
So the cause of the original dropped connection seems to be somewhere in the self._secure/axTLS codepath. Haven't gotten much farther than that debugging.