-
Notifications
You must be signed in to change notification settings - Fork 46
Description
Trying to connect two peers
- I start th-router from .bin folder.
- Save "link" from its output into links.json file:
[
"link://192.168.0.100:42424?cs1a=aot5jpsln6cladvzaljdaanined72uxzom&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqbkml5k6356vowblycjv6dczqswejtbj7h6psfnerp6j3xkqvybka7fxw2k7njlob7pygamxztwyjatcigyzogp2hpvulaj3drpn7lpnsmbndqdya2xiguighswttv5y4avqelnjo7mkniihz37mylyjc7s5upoz4a2ygwq2hz2iz7k7pro7fxx3pyizyqw2o2zpfg7qf3h4h4ttm45sxp7z42qzal5ftunkhubgol2no7bigvaoqr4i5ojbxuhfnptojryfkqldmbllfe67bjvaihxlf6gvfzzpi7hewjeewns5ctycp4amykuqtmql73qdnabtsw6lxz55snbvfs7gebyb7rmcwclhnnozjk3bkiq52u2flcq7iom4ay4s2jc4swjyaclnzsuu42igayrqlbaicamaqaai&cs3a=x2w6lnsjbehbjbirgjirwcuppgjyw6xcsf7savyl7ffrwhcv3f2a"
]
I have this peer as "first":
var th = require("telehash");
var path=require("path");
th.generate(function(err, endpoint){
if(err) return console.log("endpoint generation failed",err);
// endpoint contains a `keys:{}`, `secrets:{}`, and `hashname:"..."`
var id = endpoint;
console.log("id", id.hashname);
var mesh = th.mesh({id: id, links:path.resolve(__dirname, "./links.json")}, function(err, mesh){
if(err) return console.log("mesh failed to initialize",err);
// use mesh.* now
console.log("mesh initialized");
var routerlink = mesh.link("link://192.168.0.100:42424?cs1a=aot5jpsln6cladvzaljdaanined72uxzom&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqbkml5k6356vowblycjv6dczqswejtbj7h6psfnerp6j3xkqvybka7fxw2k7njlob7pygamxztwyjatcigyzogp2hpvulaj3drpn7lpnsmbndqdya2xiguighswttv5y4avqelnjo7mkniihz37mylyjc7s5upoz4a2ygwq2hz2iz7k7pro7fxx3pyizyqw2o2zpfg7qf3h4h4ttm45sxp7z42qzal5ftunkhubgol2no7bigvaoqr4i5ojbxuhfnptojryfkqldmbllfe67bjvaihxlf6gvfzzpi7hewjeewns5ctycp4amykuqtmql73qdnabtsw6lxz55snbvfs7gebyb7rmcwclhnnozjk3bkiq52u2flcq7iom4ay4s2jc4swjyaclnzsuu42igayrqlbaicamaqaai&cs3a=x2w6lnsjbehbjbirgjirwcuppgjyw6xcsf7savyl7ffrwhcv3f2a");
mesh.router(routerlink);
console.log(mesh.uri());
});
mesh.accept = function(from){
console.log("accept from ",from);
mesh.link(from);
};
});
and second (here I'm trying to connect to first peer)
var th = require("telehash");
var path = require("path");
th.generate(function(err, endpoint){
if(err) return console.log("endpoint generation failed",err);
// endpoint contains a `keys:{}`, `secrets:{}`, and `hashname:"..."`
var id = endpoint;
console.log("id", id.hashname);
var mesh = th.mesh({id: id, links:path.resolve(__dirname, "./links.json")}, function(err, mesh){
if(err) return console.log("mesh failed to initialize",err);
// use mesh.* now
console.log("mesh initialized");
//console.log(mesh);
var routerlink = mesh.link("link://192.168.0.100:42424?cs1a=aot5jpsln6cladvzaljdaanined72uxzom&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqbkml5k6356vowblycjv6dczqswejtbj7h6psfnerp6j3xkqvybka7fxw2k7njlob7pygamxztwyjatcigyzogp2hpvulaj3drpn7lpnsmbndqdya2xiguighswttv5y4avqelnjo7mkniihz37mylyjc7s5upoz4a2ygwq2hz2iz7k7pro7fxx3pyizyqw2o2zpfg7qf3h4h4ttm45sxp7z42qzal5ftunkhubgol2no7bigvaoqr4i5ojbxuhfnptojryfkqldmbllfe67bjvaihxlf6gvfzzpi7hewjeewns5ctycp4amykuqtmql73qdnabtsw6lxz55snbvfs7gebyb7rmcwclhnnozjk3bkiq52u2flcq7iom4ay4s2jc4swjyaclnzsuu42igayrqlbaicamaqaai&cs3a=x2w6lnsjbehbjbirgjirwcuppgjyw6xcsf7savyl7ffrwhcv3f2a");
mesh.router(routerlink);
console.log(mesh.uri());
//var link = mesh.link("dxhpiwde7s4uxwxc2e2aoo6gqrcrglfun4lkrenpjflzxkoswuza");
var link = mesh.link("link://192.168.0.100:45820?cs1a=amokq7xcb3yfvv4abffao3jaqphay3zesu&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqblq2iq7o5rhsi4bs6i4fwts5iwztffp3gpqgycrunnaoblgy5bqqbi7hfsw73u4ip7scgv4u3g5v7oxdxifdylgzanbi3w4fm7fh6vy3fqfvyd4upv3p7orj7qe4lxzdoisgm6sjdhbq7w4fqdjd2dngvdlgf4tgqdgkspkkwdiye2tmxnyovs2bhbefbmweyshmghbaa5qye2etbif6xo7imcflwo2fp6czsrsqn4i5srvg3pwhxstglpwwnxdagdl2eynxmvc55xkoq6rbxflazcra72slkh3pkp23yrhldnyxgklftf75scf3sxm7u2cyw3p27bgex5o4mmlfedxlfz65lrpwmfrep6q634ifxdkphffzqizm7ktj74knh7oy442pqisye7slbqbr6rd6heicamaqaai&cs3a=lyvdwanvovg6gu2qxmhga2ki4tbnldm57igz7ve7j7b6kuo2la4q");
// will be called when link status changes, err is undefined when link is up
link.status(function(err){
if(err) {
console.log('disconnected',err);
return;
}
console.log('connected');
//mesh.router(link);
// can do any other link.* methods
});
});
mesh.accept = function(from){
console.log("accept from ",from);
mesh.link(from);
};
});
Start it:
Log from second:
zeipt@debian:~/reps/MycelyPC2$ node ./app1
generated new id djx6k6yipaw2eiqzhd3ovpv2mtts5lytw3cl4k4jrvfpx43t6fwq
id djx6k6yipaw2eiqzhd3ovpv2mtts5lytw3cl4k4jrvfpx43t6fwq
mesh initialized
link://192.168.0.100:37595?cs1a=aj7utir2zifgafbsa7hu4vb476yh5my74a&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqbjzyfisqj5xuqwnbnnuxqqt75ln43fukue4cl5tvxwtkhmy6t3eshb3egnz6marv635anmj2q55uspa4iehunnnoiffnhdfqu2ss53b2soyw7pw443qksr4b3ehq7hzqcf74fqkn5nlsa4wvyx7rfjf4tswr7ptjh2vebhtuznpzerza6riubvv3uwxhp27quez43ny7tfxsajdemzlx7wplqo2n5psks3r25soapsyhwb7fv5imvq6pghx7b2x53prvkeeuavij2xh4yojhdxlivvc2mpklndzddbucadvgp7pds6omlpbodpk4tyi4jfzoflertgtu5jvizmbrvhouxtfilgjsuc5cuqc7exblc66btulgsxgb6z4hziff6hhqapno2c4lqbhdgvswugqv37ycamaqaai&cs3a=ojvsvqxlwsqgtlnitvxlkboj7kbejad5hbyf5fftwdbo4oxufb3q
Unhandled rejection Error: false
at Object.ensureErrorObject (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/util.js:261:20)
at Promise._rejectCallback (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/promise.js:465:22)
at Function.Promise.reject.Promise.rejected (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/promise.js:195:9)
at Object.x.send (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/e3x.js:150:35)
at Pipe.peer_send (/home/zeipt/reps/MycelyPC2/node_modules/telehash/ext/peer.js:56:16)
at Pipe. (/home/zeipt/reps/MycelyPC2/node_modules/telehash/ext/peer.js:62:17)
at Pipe.emit (events.js:106:17)
at Pipe_send as send
at /home/zeipt/reps/MycelyPC2/node_modules/telehash/lib/link.class.js:254:18
at tryCatcher (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/promise.js:503:31)
at Promise._settlePromiseAt (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/promise.js:577:18)
at Promise._settlePromises (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/promise.js:693:14)
at Async._drainQueue (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/async.js:133:10)
at Async.drainQueues (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/node_modules/subtle/node_modules/polyfill-promise/node_modules/bluebird/js/main/async.js:15:14)
tcp socket error { [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
connected
tcp closed
tcp closed
And here is log from "router":
dxhpiwde up
owwimcao>
djx6k6yi up
owwimcao>
/home/zeipt/reps/MycelyPC2/node_modules/telehash/lib/util/receive.js:52
if(dupe(dupid)) return log.debug('dropping duplicate');
^
TypeError: undefined is not a function
at Object.receive_channel as channel
at Mesh_receive as receive
at /home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/telehash-udp4/index.js:35:12
at Object.tp.pipe (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/telehash-udp4/index.js:52:21)
at Socket.receive (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/telehash-udp4/index.js:34:8)
at Socket.emit (events.js:98:17)
at UDP.onMessage (dgram.js:440:8)
Else, mesh.link with hashname never works.