diff --git a/dist/src/hub.js b/dist/src/hub.js index cd931e5c0..5a0d59222 100644 --- a/dist/src/hub.js +++ b/dist/src/hub.js @@ -19,6 +19,13 @@ const nodeinfo_1 = require("./utils/nodeinfo"); const lightning_1 = require("./utils/lightning"); const constants_1 = require("./constants"); const config_1 = require("./utils/config"); +const https = require("https"); +const pingAgent = new https.Agent({ + keepAlive: true +}); +const checkInvitesAgent = new https.Agent({ + keepAlive: true +}); const env = process.env.NODE_ENV || 'development'; const config = config_1.loadConfig(); const checkInviteHub = (params = {}) => __awaiter(void 0, void 0, void 0, function* () { @@ -32,6 +39,7 @@ const checkInviteHub = (params = {}) => __awaiter(void 0, void 0, void 0, functi return; // skip if no invites } node_fetch_1.default(config.hub_api_url + '/invites/check', { + agent: checkInvitesAgent, method: 'POST', body: JSON.stringify({ invite_strings: inviteStrings }), headers: { 'Content-Type': 'application/json' } @@ -86,17 +94,25 @@ const pingHub = (params = {}) => __awaiter(void 0, void 0, void 0, function* () const node = yield nodeinfo_1.nodeinfo(); sendHubCall(Object.assign(Object.assign({}, params), { node })); }); -const sendHubCall = (params) => { - // console.log('[hub] sending ping') - node_fetch_1.default(config.hub_api_url + '/ping', { - method: 'POST', - body: JSON.stringify(params), - headers: { 'Content-Type': 'application/json' } - }) - .catch(error => { - console.log('[hub warning]: cannot reach hub'); +function sendHubCall(params) { + return __awaiter(this, void 0, void 0, function* () { + try { + const r = yield node_fetch_1.default(config.hub_api_url + '/ping', { + agent: pingAgent, + method: 'POST', + body: JSON.stringify(params), + headers: { 'Content-Type': 'application/json' } + }); + const j = yield r.json(); + if (!(j && j.status && j.status === 'ok')) { + console.log('[hub] ping returned not ok'); + } + } + catch (e) { + console.log('[hub warning]: cannot reach hub', e); + } }); -}; +} exports.sendHubCall = sendHubCall; const pingHubInterval = (ms) => { setInterval(pingHub, ms); diff --git a/dist/src/hub.js.map b/dist/src/hub.js.map index 757af77bc..dfe58cabc 100644 --- a/dist/src/hub.js.map +++ b/dist/src/hub.js.map @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,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACzB,yCAAyC;QACzC,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IACrB,CAAC,EAAE,KAAK,CAAC,CAAA;AACX,CAAC"} \ No newline at end of file diff --git a/src/hub.ts b/src/hub.ts index 78b19b75c..eb13d3963 100644 --- a/src/hub.ts +++ b/src/hub.ts @@ -8,6 +8,14 @@ import { nodeinfo } from './utils/nodeinfo' import { loadLightning } from './utils/lightning' import constants from './constants' import {loadConfig} from './utils/config' +import * as https from 'https' + +const pingAgent = new https.Agent({ + keepAlive: true +}) +const checkInvitesAgent = new https.Agent({ + keepAlive: true +}) const env = process.env.NODE_ENV || 'development'; const config = loadConfig() @@ -26,60 +34,61 @@ const checkInviteHub = async (params = {}) => { } fetch(config.hub_api_url + '/invites/check', { + agent: checkInvitesAgent, method: 'POST', body: JSON.stringify({ invite_strings: inviteStrings }), headers: { 'Content-Type': 'application/json' } }) - .then(res => res.json()) - .then(json => { - if (json.object) { - json.object.invites.map(async object => { - const invite = object.invite - const pubkey = object.pubkey - const price = object.price - - const dbInvite = await models.Invite.findOne({ where: { inviteString: invite.pin } }) - const contact = await models.Contact.findOne({ where: { id: dbInvite.contactId } }) - - if (dbInvite.status != invite.invite_status) { - const updateObj: { [k: string]: any } = { status: invite.invite_status, price: price } - if (invite.invoice) updateObj.invoice = invite.invoice - - dbInvite.update(updateObj) - - socket.sendJson({ - type: 'invite', - response: jsonUtils.inviteToJson(dbInvite) - }) - - if (dbInvite.status == constants.invite_statuses.ready && contact) { - sendNotification(-1, contact.alias, 'invite') - } - } - - if (pubkey && dbInvite.status == constants.invite_statuses.complete && contact) { - contact.update({ publicKey: pubkey, status: constants.contact_statuses.confirmed }) - - var contactJson = jsonUtils.contactToJson(contact) - contactJson.invite = jsonUtils.inviteToJson(dbInvite) - - socket.sendJson({ - type: 'contact', - response: contactJson - }) - - helpers.sendContactKeys({ - contactIds: [contact.id], - sender: owner, - type: constants.message_types.contact_key, - }) + .then(res => res.json()) + .then(json => { + if (json.object) { + json.object.invites.map(async object => { + const invite = object.invite + const pubkey = object.pubkey + const price = object.price + + const dbInvite = await models.Invite.findOne({ where: { inviteString: invite.pin } }) + const contact = await models.Contact.findOne({ where: { id: dbInvite.contactId } }) + + if (dbInvite.status != invite.invite_status) { + const updateObj: { [k: string]: any } = { status: invite.invite_status, price: price } + if (invite.invoice) updateObj.invoice = invite.invoice + + dbInvite.update(updateObj) + + socket.sendJson({ + type: 'invite', + response: jsonUtils.inviteToJson(dbInvite) + }) + + if (dbInvite.status == constants.invite_statuses.ready && contact) { + sendNotification(-1, contact.alias, 'invite') } - }) - } - }) - .catch(error => { - console.log('[hub error]', error) - }) + } + + if (pubkey && dbInvite.status == constants.invite_statuses.complete && contact) { + contact.update({ publicKey: pubkey, status: constants.contact_statuses.confirmed }) + + var contactJson = jsonUtils.contactToJson(contact) + contactJson.invite = jsonUtils.inviteToJson(dbInvite) + + socket.sendJson({ + type: 'contact', + response: contactJson + }) + + helpers.sendContactKeys({ + contactIds: [contact.id], + sender: owner, + type: constants.message_types.contact_key, + }) + } + }) + } + }) + .catch(error => { + console.log('[hub error]', error) + }) } const pingHub = async (params = {}) => { @@ -91,16 +100,21 @@ const pingHub = async (params = {}) => { sendHubCall({ ...params, node }) } -const sendHubCall = (params) => { - // console.log('[hub] sending ping') - fetch(config.hub_api_url + '/ping', { - method: 'POST', - body: JSON.stringify(params), - headers: { 'Content-Type': 'application/json' } - }) - .catch(error => { - console.log('[hub warning]: cannot reach hub',) +async function sendHubCall(params) { + try { + const r = await fetch(config.hub_api_url + '/ping', { + agent: pingAgent, + method: 'POST', + body: JSON.stringify(params), + headers: { 'Content-Type': 'application/json' } }) + const j = await r.json() + if(!(j && j.status && j.status==='ok')) { + console.log('[hub] ping returned not ok') + } + } catch(e) { + console.log('[hub warning]: cannot reach hub',e) + } } const pingHubInterval = (ms) => {