I noticed the Web Socket Transport “Disconnects” then “Re-Connects” often and on a 60-70 interval.
I was thinking this might be normal and tied to the default URLRequest.timeoutInterval of 60 seconds but I changed it to different values (5, 10, etc) and the behavior remained the same: the socket transport disconnects and immediately re-connects every 60-70 seconds (actual times vary).
What’s causing this? Is it normal? Does it affect calls/subscriptions?
Hi @joe - I would expect socket connections to remain stable, there is no reason a socket would need to disconnect and reconnect unless intentionally closed. My suggestion is to try debug what the disconnect reason is from both the client and server, that might give us more to work with.
thanks @calvincestari from the iOS client stand point, I can debug the Apollo code to see when and why its disconnecting. I’m not sure what else can be done to determine WHY this is happening. I monitor all the delegate methods and didDisconnectWithError gets called but without an error. Do you have suggestions for iOS-side debug?
I can ask backend team to investigate, but if you have some insight there, too, that would be appreciated.
I can see that in WebSocketStream.swift the open func stream(_ aStream: Stream, handle eventCode: Stream.Event) is being called and delegate?.streamDidError(error: nil) is being called from there.
Not sure why the eventCode == .endCountered and I can deduce what that means, just don’t know why or how. Any insight?
After a bit of investigation, it looks like the device will disconnect the stream due to inactivity, but because my web socket transport is set to reconnect with 0.5s interval, it auto re-connects immediately.
Solution (I believe): The server needs to be setup to ping on an interval to keep alive – which mine is not current setup to do (ping interval on our server is set to nil; going to update and test.)
With that said, on iOS’s WebSocketTransport.init, even if I pass reconnect: false, it still does the re-connect automatically, which I assume it shouldn’t do but