{"action":"opened","issue":{"url":"https://api.github.com/repos/telehash/telehash-js/issues/47","labels_url":"https://api.github.com/repos/telehash/telehash-js/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/telehash/telehash-js/issues/47/comments","events_url":"https://api.github.com/repos/telehash/telehash-js/issues/47/events","html_url":"https://github.com/telehash/telehash-js/issues/47","id":105568583,"number":47,"title":" Router crashes with if(dupe(dupid)) return log.debug('dropping duplicate');","user":{"login":"Zeipt","id":1494434,"avatar_url":"https://avatars.githubusercontent.com/u/1494434?v=3","gravatar_id":"","url":"https://api.github.com/users/Zeipt","html_url":"https://github.com/Zeipt","followers_url":"https://api.github.com/users/Zeipt/followers","following_url":"https://api.github.com/users/Zeipt/following{/other_user}","gists_url":"https://api.github.com/users/Zeipt/gists{/gist_id}","starred_url":"https://api.github.com/users/Zeipt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zeipt/subscriptions","organizations_url":"https://api.github.com/users/Zeipt/orgs","repos_url":"https://api.github.com/users/Zeipt/repos","events_url":"https://api.github.com/users/Zeipt/events{/privacy}","received_events_url":"https://api.github.com/users/Zeipt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-09T10:26:01Z","updated_at":"2015-09-09T10:26:01Z","closed_at":null,"body":"## Trying to connect two peers\r\n\r\n1.  I start th-router from .bin folder. \r\n![- 09 09 2015 - 12 35 53](https://cloud.githubusercontent.com/assets/1494434/9758543/f5818e0e-56ef-11e5-8d29-80bbe96d3505.png)\r\n\r\n2. Save \"link\" from its output into links.json file:\r\n[\r\n\"link://192.168.0.100:42424?cs1a=aot5jpsln6cladvzaljdaanined72uxzom&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqbkml5k6356vowblycjv6dczqswejtbj7h6psfnerp6j3xkqvybka7fxw2k7njlob7pygamxztwyjatcigyzogp2hpvulaj3drpn7lpnsmbndqdya2xiguighswttv5y4avqelnjo7mkniihz37mylyjc7s5upoz4a2ygwq2hz2iz7k7pro7fxx3pyizyqw2o2zpfg7qf3h4h4ttm45sxp7z42qzal5ftunkhubgol2no7bigvaoqr4i5ojbxuhfnptojryfkqldmbllfe67bjvaihxlf6gvfzzpi7hewjeewns5ctycp4amykuqtmql73qdnabtsw6lxz55snbvfs7gebyb7rmcwclhnnozjk3bkiq52u2flcq7iom4ay4s2jc4swjyaclnzsuu42igayrqlbaicamaqaai&cs3a=x2w6lnsjbehbjbirgjirwcuppgjyw6xcsf7savyl7ffrwhcv3f2a\"\r\n]\r\n\r\nI have this peer as \"first\": \r\n```javascript\r\nvar th = require(\"telehash\");\r\nvar path=require(\"path\");\r\n\r\nth.generate(function(err, endpoint){\r\n\tif(err) return console.log(\"endpoint generation failed\",err);\r\n\t// endpoint contains a `keys:{}`, `secrets:{}`, and `hashname:\"...\"`\r\n\tvar id = endpoint;\r\n\tconsole.log(\"id\", id.hashname);\r\n\tvar mesh = th.mesh({id: id, links:path.resolve(__dirname, \"./links.json\")}, function(err, mesh){\r\n\t\t  if(err) return console.log(\"mesh failed to initialize\",err);\r\n\t\t  // use mesh.* now\r\n\t\t\tconsole.log(\"mesh initialized\");\r\n\t\tvar routerlink = mesh.link(\"link://192.168.0.100:42424?cs1a=aot5jpsln6cladvzaljdaanined72uxzom&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqbkml5k6356vowblycjv6dczqswejtbj7h6psfnerp6j3xkqvybka7fxw2k7njlob7pygamxztwyjatcigyzogp2hpvulaj3drpn7lpnsmbndqdya2xiguighswttv5y4avqelnjo7mkniihz37mylyjc7s5upoz4a2ygwq2hz2iz7k7pro7fxx3pyizyqw2o2zpfg7qf3h4h4ttm45sxp7z42qzal5ftunkhubgol2no7bigvaoqr4i5ojbxuhfnptojryfkqldmbllfe67bjvaihxlf6gvfzzpi7hewjeewns5ctycp4amykuqtmql73qdnabtsw6lxz55snbvfs7gebyb7rmcwclhnnozjk3bkiq52u2flcq7iom4ay4s2jc4swjyaclnzsuu42igayrqlbaicamaqaai&cs3a=x2w6lnsjbehbjbirgjirwcuppgjyw6xcsf7savyl7ffrwhcv3f2a\");\r\n\t\tmesh.router(routerlink);\r\n\t\tconsole.log(mesh.uri());\r\n\t});\r\n\t\r\n\tmesh.accept = function(from){\r\n\t\tconsole.log(\"accept from \",from);\r\n\t\tmesh.link(from);\r\n\t};\r\n});\r\n```\r\nStart it:\r\n![- 09 09 2015 - 12 48 59](https://cloud.githubusercontent.com/assets/1494434/9758753/34a87fc4-56f1-11e5-8e04-8fd5f4731fc1.png)\r\n\r\n\r\nand second (here I'm trying to connect to first peer)\r\n```javascript\r\nvar th = require(\"telehash\");\r\nvar path = require(\"path\");\r\n\r\nth.generate(function(err, endpoint){\r\n\tif(err) return console.log(\"endpoint generation failed\",err);\r\n\t// endpoint contains a `keys:{}`, `secrets:{}`, and `hashname:\"...\"`\r\n\tvar id = endpoint;\r\n\tconsole.log(\"id\", id.hashname);\r\n\tvar mesh = th.mesh({id: id, links:path.resolve(__dirname, \"./links.json\")}, function(err, mesh){\r\n\t\tif(err) return console.log(\"mesh failed to initialize\",err);\r\n\t\t// use mesh.* now\r\n\t\tconsole.log(\"mesh initialized\");\r\n\t\t //console.log(mesh);\r\n\t\tvar routerlink = mesh.link(\"link://192.168.0.100:42424?cs1a=aot5jpsln6cladvzaljdaanined72uxzom&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqbkml5k6356vowblycjv6dczqswejtbj7h6psfnerp6j3xkqvybka7fxw2k7njlob7pygamxztwyjatcigyzogp2hpvulaj3drpn7lpnsmbndqdya2xiguighswttv5y4avqelnjo7mkniihz37mylyjc7s5upoz4a2ygwq2hz2iz7k7pro7fxx3pyizyqw2o2zpfg7qf3h4h4ttm45sxp7z42qzal5ftunkhubgol2no7bigvaoqr4i5ojbxuhfnptojryfkqldmbllfe67bjvaihxlf6gvfzzpi7hewjeewns5ctycp4amykuqtmql73qdnabtsw6lxz55snbvfs7gebyb7rmcwclhnnozjk3bkiq52u2flcq7iom4ay4s2jc4swjyaclnzsuu42igayrqlbaicamaqaai&cs3a=x2w6lnsjbehbjbirgjirwcuppgjyw6xcsf7savyl7ffrwhcv3f2a\");\r\n\t\tmesh.router(routerlink);\r\n\t\tconsole.log(mesh.uri());\r\n\t\t//var link = mesh.link(\"dxhpiwde7s4uxwxc2e2aoo6gqrcrglfun4lkrenpjflzxkoswuza\");\r\n\t\tvar link = mesh.link(\"link://192.168.0.100:45820?cs1a=amokq7xcb3yfvv4abffao3jaqphay3zesu&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqblq2iq7o5rhsi4bs6i4fwts5iwztffp3gpqgycrunnaoblgy5bqqbi7hfsw73u4ip7scgv4u3g5v7oxdxifdylgzanbi3w4fm7fh6vy3fqfvyd4upv3p7orj7qe4lxzdoisgm6sjdhbq7w4fqdjd2dngvdlgf4tgqdgkspkkwdiye2tmxnyovs2bhbefbmweyshmghbaa5qye2etbif6xo7imcflwo2fp6czsrsqn4i5srvg3pwhxstglpwwnxdagdl2eynxmvc55xkoq6rbxflazcra72slkh3pkp23yrhldnyxgklftf75scf3sxm7u2cyw3p27bgex5o4mmlfedxlfz65lrpwmfrep6q634ifxdkphffzqizm7ktj74knh7oy442pqisye7slbqbr6rd6heicamaqaai&cs3a=lyvdwanvovg6gu2qxmhga2ki4tbnldm57igz7ve7j7b6kuo2la4q\");\r\n\t\t// will be called when link status changes, err is undefined when link is up\r\n\t\tlink.status(function(err){\r\n\t\t\tif(err) {\r\n\t\t\t    console.log('disconnected',err);\r\n\t\t\t    return;\r\n\t\t\t}\r\n\t\t\t console.log('connected');\r\n\t\t\t //mesh.router(link);\r\n\t\t\t // can do any other link.* methods\r\n\t\t});\r\n\t\t\r\n\t\t\r\n\t});\r\n\t\r\n\tmesh.accept = function(from){\r\n\t\tconsole.log(\"accept from \",from);\r\n\t\tmesh.link(from);\r\n\t};\r\n});\r\n\r\n```\r\nStart it:\r\n\r\n\r\nLog from second:\r\nzeipt@debian:~/reps/MycelyPC2$ node ./app1\r\ngenerated new id djx6k6yipaw2eiqzhd3ovpv2mtts5lytw3cl4k4jrvfpx43t6fwq\r\nid djx6k6yipaw2eiqzhd3ovpv2mtts5lytw3cl4k4jrvfpx43t6fwq\r\nmesh initialized\r\nlink://192.168.0.100:37595?cs1a=aj7utir2zifgafbsa7hu4vb476yh5my74a&cs2a=gcbacirqbudaskugjcdpodibaeaqkaadqiaq6abqqiaquaucaeaqbjzyfisqj5xuqwnbnnuxqqt75ln43fukue4cl5tvxwtkhmy6t3eshb3egnz6marv635anmj2q55uspa4iehunnnoiffnhdfqu2ss53b2soyw7pw443qksr4b3ehq7hzqcf74fqkn5nlsa4wvyx7rfjf4tswr7ptjh2vebhtuznpzerza6riubvv3uwxhp27quez43ny7tfxsajdemzlx7wplqo2n5psks3r25soapsyhwb7fv5imvq6pghx7b2x53prvkeeuavij2xh4yojhdxlivvc2mpklndzddbucadvgp7pds6omlpbodpk4tyi4jfzoflertgtu5jvizmbrvhouxtfilgjsuc5cuqc7exblc66btulgsxgb6z4hziff6hhqapno2c4lqbhdgvswugqv37ycamaqaai&cs3a=ojvsvqxlwsqgtlnitvxlkboj7kbejad5hbyf5fftwdbo4oxufb3q\r\nUnhandled rejection Error: false\r\n    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)\r\n    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)\r\n    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)\r\n    at Object.x.send (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/e3x/e3x.js:150:35)\r\n    at Pipe.peer_send (/home/zeipt/reps/MycelyPC2/node_modules/telehash/ext/peer.js:56:16)\r\n    at Pipe.<anonymous> (/home/zeipt/reps/MycelyPC2/node_modules/telehash/ext/peer.js:62:17)\r\n    at Pipe.emit (events.js:106:17)\r\n    at Pipe_send [as send] (/home/zeipt/reps/MycelyPC2/node_modules/telehash/lib/pipe.class.js:75:10)\r\n    at /home/zeipt/reps/MycelyPC2/node_modules/telehash/lib/link.class.js:254:18\r\n    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)\r\n    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)\r\n    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)\r\n    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)\r\n    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)\r\n    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)\r\n    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)\r\ntcp socket error { [Error: connect ECONNREFUSED]\r\n  code: 'ECONNREFUSED',\r\n  errno: 'ECONNREFUSED',\r\n  syscall: 'connect' }\r\nconnected\r\ntcp closed\r\ntcp closed\r\n\r\nAnd here is log from \"router\":\r\ndxhpiwde up \r\nowwimcao> \r\ndjx6k6yi up \r\nowwimcao> \r\n/home/zeipt/reps/MycelyPC2/node_modules/telehash/lib/util/receive.js:52\r\n      if(dupe(dupid)) return log.debug('dropping duplicate');\r\n         ^\r\nTypeError: undefined is not a function\r\n    at Object.receive_channel [as channel] (/home/zeipt/reps/MycelyPC2/node_modules/telehash/lib/util/receive.js:52:10)\r\n    at Mesh_receive [as receive] (/home/zeipt/reps/MycelyPC2/node_modules/telehash/lib/mesh.class.js:263:20)\r\n    at /home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/telehash-udp4/index.js:35:12\r\n    at Object.tp.pipe (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/telehash-udp4/index.js:52:21)\r\n    at Socket.receive (/home/zeipt/reps/MycelyPC2/node_modules/telehash/node_modules/telehash-udp4/index.js:34:8)\r\n    at Socket.emit (events.js:98:17)\r\n    at UDP.onMessage (dgram.js:440:8)\r\n\r\n\r\nElse, mesh.link with hashname never works.\r\n"}}