Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

FCM tokens are not sent to endurance #116

Closed
sstone opened this issue Feb 4, 2021 · 2 comments
Closed

FCM tokens are not sent to endurance #116

sstone opened this issue Feb 4, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@sstone
Copy link
Member

sstone commented Feb 4, 2021

FCM tokens, used to send notification to Phoenix, are supposed to be sent to endurance (using a custom LN message) when the seed is loaded but it does not seems to be reliable.

What we do is:

    private suspend fun sendToPeer(msg: LightningMessage) {
        val encoded = LightningMessage.encode(msg)
        logger.info { "n:$remoteNodeId sending $msg" }
        output.send(encoded)
    }

    // The (node_id, fcm_token) tuple only needs to be registered once.
    // And after that, only if the tuple changes (e.g. different fcm_token).
    fun registerFcmToken(token: String?) {
        val msg = FCMToken(token)
        launch { sendToPeer(msg) }
    }

=> What happens if the tcp connection has not been established yet when registerFcmToken() is called? Will the outgoing message stay in output to be picked up once we are connected, or will it be lost ? @romainbsl what do you think ?

@sstone sstone added the bug Something isn't working label Feb 4, 2021
@romainbsl
Copy link
Contributor

I think output won't lose any message, unless its buffer goes beyond 64 elements. I pretty confident that this might not be the case here, but still can be kept in mind for deeper investigation.

However, looking at the Phoenix code, the mistake is mine.
I've refactored the way the Peer is handle, and ended with something like:

    fun registerFcmToken(token: String?) {
        peerManager.peerState.value?.registerFcmToken(token)
    }

So if the state is null, the message is lost here. I can handle a fix for this if needed.

@sstone
Copy link
Member Author

sstone commented Feb 4, 2021

Yes please :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants