From 726c7aac248e673a437c8894250c4bbcbf1fbcf9 Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Tue, 12 May 2020 09:41:01 -0700 Subject: [PATCH] actual conn --- api/controllers/chats.ts | 2 +- api/network/receive.ts | 2 ++ api/utils/tribes.ts | 9 ++++++--- config/app.json | 2 +- dist/api/network/receive.js | 2 ++ dist/api/network/receive.js.map | 2 +- dist/api/utils/tribes.js | 9 ++++++--- dist/api/utils/tribes.js.map | 2 +- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/api/controllers/chats.ts b/api/controllers/chats.ts index 5c871c5..27c7f9f 100644 --- a/api/controllers/chats.ts +++ b/api/controllers/chats.ts @@ -501,4 +501,4 @@ async function asyncForEach(array, callback) { for (let index = 0; index < array.length; index++) { await callback(array[index], index, array); } -} \ No newline at end of file +} diff --git a/api/network/receive.ts b/api/network/receive.ts index a57dfb3..7e6ac8b 100644 --- a/api/network/receive.ts +++ b/api/network/receive.ts @@ -38,6 +38,8 @@ async function forwardMessageToTribe(payload){ const owner = await models.Contact.findOne({where:{isOwner:true}}) const type = payload.type const message = payload.message + // HERE: NEED TO MAKE SURE ALIAS IS UNIQUE + // ASK xref TABLE and put alias there too? sendMessage({ sender: { ...owner.dataValues, // ADD IN REAL ALIAS HERE??! diff --git a/api/utils/tribes.ts b/api/utils/tribes.ts index f397789..e3bf009 100644 --- a/api/utils/tribes.ts +++ b/api/utils/tribes.ts @@ -17,8 +17,8 @@ export async function connect(onMessage) { async function reconnect(){ client = null const pwd = await genSignedTimestamp() - console.log('[tribes] try to connect:',`tcp://${config.tribes_host}`) - client = mqtt.connect(`tcp://${config.tribes_host}`,{ + console.log('[tribes] try to connect:',`tls://${config.tribes_host}`) + client = mqtt.connect(`tls://${config.tribes_host}`,{ username:info.identity_pubkey, password:pwd, reconnectPeriod:0, // dont auto reconnect @@ -27,9 +27,12 @@ export async function connect(onMessage) { console.log("[tribes] connected!") client.subscribe(`${info.identity_pubkey}/#`) }) - client.on('close', function () { + client.on('close', function (e) { setTimeout(()=> reconnect(), 2000) }) + client.on('error', function (e) { + console.log('[tribes] error: ',e) + }) client.on('message', function(topic, message) { if(onMessage) onMessage(topic, message) }) diff --git a/config/app.json b/config/app.json index 887cdf3..250cc7a 100644 --- a/config/app.json +++ b/config/app.json @@ -12,7 +12,7 @@ "hub_invite_url": "http://lvh.me/invites", "hub_check_invite_url": "http://lvh.me/check_invite", "media_host": "localhost:5000", - "tribes_host": "127.0.0.1:1883" + "tribes_host": "tribes.sphinx.chat:8883" }, "production": { "senza_url": "https://staging.senza.us/api/v2/", diff --git a/dist/api/network/receive.js b/dist/api/network/receive.js index 18e3d7d..a0e3a5e 100644 --- a/dist/api/network/receive.js +++ b/dist/api/network/receive.js @@ -50,6 +50,8 @@ function forwardMessageToTribe(payload) { const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const type = payload.type; const message = payload.message; + // HERE: NEED TO MAKE SURE ALIAS IS UNIQUE + // ASK xref TABLE and put alias there too? send_1.sendMessage({ sender: Object.assign(Object.assign({}, owner.dataValues), payload.sender && payload.sender.alias && { alias: payload.sender.alias }), chat, type, message, diff --git a/dist/api/network/receive.js.map b/dist/api/network/receive.js.map index 6f07fe8..d581422 100644 --- a/dist/api/network/receive.js.map +++ b/dist/api/network/receive.js.map @@ -1 +1 @@ -{"version":3,"file":"receive.js","sourceRoot":"","sources":["../../../api/network/receive.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA4B;AAC5B,sCAAqC;AACrC,kDAA0C;AAC1C,gDAA0C;AAC1C,0CAAyC;AACzC,kDAAwE;AACxE,sCAAkC;AAClC,iCAAkC;AAElC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,6BAA6B,CAAC,CAAC,CAAA;AAC7E,MAAM,KAAK,GAAG,SAAS,CAAC,aAAa,CAAA;AAErC,MAAM,cAAc,GAAC;IACpB,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU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AQ,CAAC,CAAC,CAAC,EAAC;QAClC,cAAc;QACd,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;QACtB,IAAI,OAAO,GAAG,EAAE,CAAA;QAChB,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAA,CAAC,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAA,EAAE;YAC7C,OAAO,IAAI,GAAG,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,EAAE,CAAC,CAAA;QACjB,OAAO,OAAO,CAAA;KACd;AACF,CAAC"} \ No newline at end of file +{"version":3,"file":"receive.js","sourceRoot":"","sources":["../../../api/network/receive.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA4B;AAC5B,sCAAqC;AACrC,kDAA0C;AAC1C,gDAA0C;AAC1C,0CAAyC;AACzC,kDAAwE;AACxE,sCAAkC;AAClC,iCAAkC;AAElC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,6BAA6B,CAAC,CAAC,CAAA;AAC7E,MAAM,KAAK,GAAG,SAAS,CAAC,aAAa,CAAA;AAErC,MAAM,cAAc,GAAC;IACpB,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW;CACpE,CAAA;AACD,SAAe,SAAS,CAAC,OAAO;;QAC/B,uCAAuC;QACvC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAC,OAAO,CAAC,CAAA;QACvC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,KAAG,SAAS,CAAC,UAAU,CAAC,KAAK,CAAA;QAC9D,IAAG,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAC;YACnD,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I,GAAG,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,EAAE,CAAC,CAAA;QACjB,OAAO,OAAO,CAAA;KACd;AACF,CAAC"} \ No newline at end of file diff --git a/dist/api/utils/tribes.js b/dist/api/utils/tribes.js index 8ddecf7..d8ad989 100644 --- a/dist/api/utils/tribes.js +++ b/dist/api/utils/tribes.js @@ -25,8 +25,8 @@ function connect(onMessage) { return __awaiter(this, void 0, void 0, function* () { client = null; const pwd = yield genSignedTimestamp(); - console.log('[tribes] try to connect:', `tcp://${config.tribes_host}`); - client = mqtt.connect(`tcp://${config.tribes_host}`, { + console.log('[tribes] try to connect:', `tls://${config.tribes_host}`); + client = mqtt.connect(`tls://${config.tribes_host}`, { username: info.identity_pubkey, password: pwd, reconnectPeriod: 0, @@ -35,9 +35,12 @@ function connect(onMessage) { console.log("[tribes] connected!"); client.subscribe(`${info.identity_pubkey}/#`); }); - client.on('close', function () { + client.on('close', function (e) { setTimeout(() => reconnect(), 2000); }); + client.on('error', function (e) { + console.log('[tribes] error: ', e); + }); client.on('message', function (topic, message) { if (onMessage) onMessage(topic, message); diff --git a/dist/api/utils/tribes.js.map b/dist/api/utils/tribes.js.map index f46619c..bc9d866 100644 --- a/dist/api/utils/tribes.js.map +++ b/dist/api/utils/tribes.js.map @@ -1 +1 @@ -{"version":3,"file":"tribes.js","sourceRoot":"","sources":["../../../api/utils/tribes.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,iCAAgC;AAChC,qCAAoC;AACpC,mCAAkC;AAClC,6BAA4B;AAC5B,6BAA4B;AAE5B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAA;AACjD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEzE,IAAI,MAAU,CAAA;AAEd,SAAsB,OAAO,CAAC,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