Sticky session using cookies and cordova

Hello!

I’m using kubernetes and nginx ingress to load balance my meteor app. Nginx ingress supports only cookie approach for session affinity and in case of browser everything works fine. I also have a cordova application which communicates with meteor server over dpp with web sockets only but as far as I know both android and ios cordova webviews doesn’t support cookies. The question is what should I do to load balance traffic coming from my cordova application with sticky session?

It’s quite important, galaxy also uses cookie based sticky session and meteor is supposed to support cordova apps.

I also don’t know the answer and interested with this topic since I’m developing cordova apps

If you don’t mind, do you have a server feature that requires sticky sessions?

I am sure that SockJS requires sticky sessions, in case of cordova I think DDP also requires sticky session even if the app uses native WebSockets. When your cordova app is being closed or backgrounded the web socket connection will be destroyed and next time you open then app it will create new DDP connection so your app could connect to different server if there is no sticky session support. This behavior leads to much higher load on server and client because from the point after reconnecting the server would know nothing about the client and it will send all the data the client is subscribed even if the client already has all the data.

When I checked the server connection chapter in the meteor documentation, it was mentioned that

Currently when a client reconnects to the server (such as after temporarily losing its Internet connection), it will get a new connection each time.

Right, that’s why we need sticky session

So this is not about being load balanced or not. What you need first is for DDP to restore the same connection when the app reconnects even with the same server.

Or do you already solved that part? Persistent DDP connection for the same server that reuses old DDP connections on reconnect?

I am not sure but I think that meteor keeps some DDP cache for every user, so it shouldn’t be a problem that for every reconnect new connection is being established. The problem is that when client reconnects it should connect to the same server because other servers have zero information about previous DDP session.

we also use sticky sessions, but that seems to be broken in current ios versions as cookies are no longer stored. Has anyone managed to fix this?

@macrozone

You might want to give feature: adds setCookie/deleteCookie by menelike · Pull Request #15 · GEDYSIntraWare/cordova-plugin-webview-proxy · GitHub a try.

GitHub - risetechnologies/cookieTest: ostrio:cookies test app shows how it can be used.

I wonder why we’re the only ones who noticed this, it’s like there are no other Meteor/Cordova/iOS users who use load balancers with sticky sessions and cookies ? :man_shrugging:

IMHO this is a critical issue.


1 Like

thx, at some point we could fix it (i don’t remember how)… but it recently broke again. We have currently re-enabled websockets that do not require sticky session for this one meteor-cordova-project we have and we do not create new projects with meteor and/or cordova anymore.