{"action":"created","issue":{"url":"https://api.github.com/repos/bitpay/bitcore-p2p/issues/89","repository_url":"https://api.github.com/repos/bitpay/bitcore-p2p","labels_url":"https://api.github.com/repos/bitpay/bitcore-p2p/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/bitpay/bitcore-p2p/issues/89/comments","events_url":"https://api.github.com/repos/bitpay/bitcore-p2p/issues/89/events","html_url":"https://github.com/bitpay/bitcore-p2p/issues/89","id":188782502,"number":89,"title":"Can't connect Peer to localhost node","user":{"login":"frz-dev","id":8609060,"avatar_url":"https://avatars.githubusercontent.com/u/8609060?v=3","gravatar_id":"","url":"https://api.github.com/users/frz-dev","html_url":"https://github.com/frz-dev","followers_url":"https://api.github.com/users/frz-dev/followers","following_url":"https://api.github.com/users/frz-dev/following{/other_user}","gists_url":"https://api.github.com/users/frz-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/frz-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frz-dev/subscriptions","organizations_url":"https://api.github.com/users/frz-dev/orgs","repos_url":"https://api.github.com/users/frz-dev/repos","events_url":"https://api.github.com/users/frz-dev/events{/privacy}","received_events_url":"https://api.github.com/users/frz-dev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-11T15:20:39Z","updated_at":"2016-11-14T17:17:36Z","closed_at":null,"body":"Hi,\r\nI'm trying to run a simple script, like this:\r\n```\r\nvar bitcore = require('bitcore-lib')\r\nvar p2p = require('bitcore-p2p')\r\nvar Peer = p2p.Peer;\r\n\r\nvar peer = new Peer({host: 'localhost', port: 3001, network: tBTC})\r\npeer.on('connect', function () { console.log('connect'); })\r\npeer.on('connected', function(){  console.log('connected'); });\r\npeer.on('disconnect', function() {  console.log('connection closed'); });\r\npeer.connect()\r\n```\r\n\r\nHowever, the connection seems to be never established... \r\nI only get the 'connect' and the 'connection closed' output.\r\n\r\nThe port is the one specified on the node config file:\r\n```\r\n{\r\n  \"network\": \"testnet\",\r\n  \"port\": 3001,\r\n  \"services\": [\r\n    \"bitcoind\",\r\n    \"bitcore-wallet-service\",\r\n    \"insight-api\",\r\n    \"insight-ui\",\r\n    \"web\"\r\n  ],\r\n  \"servicesConfig\": {\r\n    \"bitcoind\": {\r\n      \"spawn\": {\r\n        \"datadir\": \"./data\",\r\n        \"exec\": \"/home/user/.nvm/versions/node/v4.6.0/lib/node_modules/bitcore/node_modules/bitcore-node/bin/bitcoind\"\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n\r\nWhat am I doing wrong?\r\n"},"comment":{"url":"https://api.github.com/repos/bitpay/bitcore-p2p/issues/comments/260398984","html_url":"https://github.com/bitpay/bitcore-p2p/issues/89#issuecomment-260398984","issue_url":"https://api.github.com/repos/bitpay/bitcore-p2p/issues/89","id":260398984,"user":{"login":"frz-dev","id":8609060,"avatar_url":"https://avatars.githubusercontent.com/u/8609060?v=3","gravatar_id":"","url":"https://api.github.com/users/frz-dev","html_url":"https://github.com/frz-dev","followers_url":"https://api.github.com/users/frz-dev/followers","following_url":"https://api.github.com/users/frz-dev/following{/other_user}","gists_url":"https://api.github.com/users/frz-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/frz-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frz-dev/subscriptions","organizations_url":"https://api.github.com/users/frz-dev/orgs","repos_url":"https://api.github.com/users/frz-dev/repos","events_url":"https://api.github.com/users/frz-dev/events{/privacy}","received_events_url":"https://api.github.com/users/frz-dev/received_events","type":"User","site_admin":false},"created_at":"2016-11-14T17:17:36Z","updated_at":"2016-11-14T17:17:36Z","body":"After many tries, I figured out that:\r\n1) the port number should actually be that of the Bitcoind server (default 8333, or 18333 for testnet)\r\n2) when connecting to a livenet peer, the code works perfectly, but when connecting to a testnet node it immediately disconnect. I tried both with my node, and with a public one.\r\n\r\nSo, it seems to me that this is a bug of the bitcore-p2p library.\r\nOtherwise, there is something different with testnet peers that I am not aware of.\r\n\r\nIn any case, I need some help (I cannot develop using the mainnet...)"}}
{"actor":{"display_login":"frz-dev"}}