Browse Source

Reconnecting on error as well if it's unavailable

feature/dockerfile-arm
Gonzalo Javier Aune 5 years ago
parent
commit
42d943b000
  1. 9
      api/grpc/index.ts
  2. 10
      dist/api/grpc/index.js
  3. 2
      dist/api/grpc/index.js.map

9
api/grpc/index.ts

@ -10,7 +10,6 @@ import * as path from 'path'
const constants = require(path.join(__dirname,'../../config/constants.json'))
const ERR_CODE_UNAVAILABLE = 14
const ERR_CODE_UNIMPLEMENTED = 12
// VERIFY PUBKEY OF SENDER
async function parseAndVerifyPayload(data){
@ -174,7 +173,7 @@ function subscribeInvoices(actions) {
call.on('status', function(status) {
console.log("Status", status);
// The server is unavailable, trying to reconnect.
if (status.code == ERR_CODE_UNAVAILABLE || status.code == ERR_CODE_UNIMPLEMENTED) {
if (status.code == ERR_CODE_UNAVAILABLE) {
reconnectToLND();
} else {
resolve(status);
@ -182,7 +181,11 @@ function subscribeInvoices(actions) {
})
call.on('error', function(err){
console.error(err)
reject(err)
if (err.code == ERR_CODE_UNAVAILABLE) {
reconnectToLND();
} else {
reject(err)
}
})
call.on('end', function() {
const now = moment().format('YYYY-MM-DD HH:mm:ss').trim();

10
dist/api/grpc/index.js

@ -20,7 +20,6 @@ const moment = require("moment");
const path = require("path");
const constants = require(path.join(__dirname, '../../config/constants.json'));
const ERR_CODE_UNAVAILABLE = 14;
const ERR_CODE_UNIMPLEMENTED = 12;
// VERIFY PUBKEY OF SENDER
function parseAndVerifyPayload(data) {
return __awaiter(this, void 0, void 0, function* () {
@ -185,7 +184,7 @@ function subscribeInvoices(actions) {
call.on('status', function (status) {
console.log("Status", status);
// The server is unavailable, trying to reconnect.
if (status.code == ERR_CODE_UNAVAILABLE || status.code == ERR_CODE_UNIMPLEMENTED) {
if (status.code == ERR_CODE_UNAVAILABLE) {
reconnectToLND();
}
else {
@ -194,7 +193,12 @@ function subscribeInvoices(actions) {
});
call.on('error', function (err) {
console.error(err);
reject(err);
if (err.code == ERR_CODE_UNAVAILABLE) {
reconnectToLND();
}
else {
reject(err);
}
});
call.on('end', function () {
const now = moment().format('YYYY-MM-DD HH:mm:ss').trim();

2
dist/api/grpc/index.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save