I'm still a bit new to Couchbase and iOS, but I'm running into a problem restarting my replications that I'm having trouble with. Here are a few notes about the flow.
-user logs in by sending username and password
-backend validates pw and then creates a session on the sync gateway for the user using the admin port
-backend responds with session to app
-app uses the provided session to start a push and pull replication and sets the cookie with the info received. Continuous to true. A UUID header is added.
-each call by the replicator will go to the app server who validates the session against the sync gateway and the user's login info, stored elsewhere. If everything is good, the call is simply forwarded to the sync gateway.
The cookies are good for 24 hours but after 12 hours, any calls with that cookie will cause the backend to respond with a 401 prompting the app to get a new session. Since the first cookie is still good, the app then makes a call to the backend using it's current cookie to get a new one. Once the app gets a new cookie back, it stops the replications, updates the cookie, and starts them again.
After logging in, the replication starts up great and replicates fine, passing through my app and auth servers. However, when it's time to update the token, the replication successfully gets the new session and puts it in the headers and starts up. However, the replications just stay stuck in an ACTIVE state at that point and don't pull any new docs on their channels or anything.
Has anybody else ran across this? Is this an OK approach to custom authentication alongside couchbase and SG anyhow?
Any input is appreciated. I'm happy to put up some code if it helps.