Sticky session using cookies and cordova


#1

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?


#2

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


#3

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?


#4

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.


#5

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.


#6

Right, that’s why we need sticky session


#7

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.


#8

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


#9

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.