EventSource icon indicating copy to clipboard operation
EventSource copied to clipboard

Cannot reconnect after an hour

Open thoughtcastapp opened this issue 4 years ago • 0 comments

I am able to get IK Event Source to connect to Firebase Auth, but after an hour (3600 seconds), I get this error:

FirebaseRestIO - server disconnected at 2020-11-08 18:03:39 +0000, statusCode Optional(200), reconnect Optional(false), error nil FirebaseRestIO - server disconnected at 2020-11-08 18:03:39 +0000, statusCode Optional(200), reconnect Optional(false), error nil FirebaseRestIO - server disconnected at 2020-11-08 18:03:39 +0000, statusCode Optional(200), reconnect Optional(false), error nil 2020-11-08 10:03:39.048403-0800 AppClip[1416:1175988] [tcp] tcp_input [C7.1:3] flags=[R] seq=2563947538, ack=0, win=0 state=LAST_ACK rcv_nxt=2563947538, snd_una=4161085012 2020-11-08 10:03:39.048818-0800 AppClip[1416:1175988] [tcp] tcp_input [C6.1:3] flags=[R] seq=314776546, ack=0, win=0 state=LAST_ACK rcv_nxt=314776546, snd_una=1638104157 2020-11-08 10:03:39.049116-0800 AppClip[1416:1175988] [tcp] tcp_input [C8.1:3] flags=[R] seq=1689482087, ack=0, win=0 state=LAST_ACK rcv_nxt=1689482087, snd_una=1980646324 2020-11-08 10:03:39.053274-0800 AppClip[1416:1175988] [tcp] tcp_input [C7.1:3] flags=[R] seq=2563947538, ack=0, win=0 state=CLOSED rcv_nxt=2563947538, snd_una=4161085012 2020-11-08 10:03:39.053536-0800 AppClip[1416:1175988] [tcp] tcp_input [C6.1:3] flags=[R] seq=314776546, ack=0, win=0 state=CLOSED rcv_nxt=314776546, snd_una=1638104157 2020-11-08 10:03:39.054742-0800 AppClip[1416:1175988] [tcp] tcp_input [C8.1:3] flags=[R] seq=1689482087, ack=0, win=0 state=CLOSED rcv_nxt=1689482087, snd_una=1980646324

I have eventSource?.onComplete set up to check if the id token is still valid, and if not to fetch a new one from firebase auth, but for some reason eventSource?.connect() isn't reconnecting...below is my code, any ideas what is going on?

` eventSource?.onComplete({ (statusCode, reconnect, error) in

                guard reconnect ?? false else { return }
                
                let retryTime = self.eventSource?.retryTime ?? 3000
                DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(retryTime)) { [weak self] in
                    if GlobalEnvironment_AppClip.shared.currentSessionCode == nil {
                        print("FirebaseRestIO - no currentSessionCode, not trying reconnect")
                    } else if self!.idToken == "" {
                        print("FirebaseRestIO - anon account made, trying to reconnect")
                        self!.makeAnonAccount {
                            
                            self!.getNewIDToken {
                                self?.eventSource?.connect()
                            }
                            
                            
                        }
                    } else if self!.currentTime > self!.codeExpireTime {
                        self?.getNewIDToken {
                            print("FirebaseRestIO - new id token made, trying to reconnect")
                            self?.eventSource?.connect()
                        }
                    } else {
                        print("FirebaseRestIO - server disconnected, trying to reconnect")
                        self?.eventSource?.connect()
                    }
                    
                }
            })

`

thoughtcastapp avatar Nov 08 '20 18:11 thoughtcastapp