Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot reconnect after an hour #145

Open
thoughtcastapp opened this issue Nov 8, 2020 · 0 comments
Open

Cannot reconnect after an hour #145

thoughtcastapp opened this issue Nov 8, 2020 · 0 comments

Comments

@thoughtcastapp
Copy link

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()
                    }
                    
                }
            })

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant