MatthieuLemoine / electron-push-receiver

A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).
https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0
MIT License
194 stars 69 forks source link

socket timeout problem #6

Closed kimorkim closed 7 years ago

kimorkim commented 7 years ago

over time, the socket is closed. then the following error occurs:

Error: Error: read ETIMEDOUT
    at TLSSocket.socket.on.error (/Users/Naver/entry-hw/node_modules/push-receiver/src/client/socket/index.js:56:11)
    at emitOne (events.js:101:20)
    at TLSSocket.emit (events.js:191:7)
    at emitErrorNT (net.js:1283:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
Socket closed

the problem is that this is not caught in try ~ catch.

electron-push-receiver/src/index.js

try {
// ...
} catch (e) {
    console.error('PUSH_RECEIVER:::Error while starting the service', e);
    // Forward error to the renderer process
    webContents.send(NOTIFICATION_SERVICE_ERROR, e.message); // <-- not working
}

for this, i wrote the following code in the main process:

process.on('uncaughtException', function (error) {
    // Handle the error
    console.log(error);
});

i don't know why try ~ catch doesn't work.

and how do i reconnect after i close the socket?

electron version: 1.7.8 os: osx el capitan

kimorkim commented 7 years ago

it seems the is has changed from the new version. i`ll check it out.