librelist archives

« back to archive

WebFaction and intermittent session variables

WebFaction and intermittent session variables

From:
Leslie Cordell
Date:
2013-02-23 @ 21:44
Hi everyone,
I wanted to provide a little solution to anyone else fairly new to WSGI 
and Flask like myself. I've already created one medium sized app which I 
put on a personal apache webserver, however after trying to put an app 
on WebFaction, I found my session variables would sometimes be there and 
other times not; logged in on a refresh, not on a few others. I spent 
around 9 hours in total banging my head on this one, I looked into 
cookie size, I even restructured all of my code into one file out of 
curiosity to see if that was the issue, I took KVSession off of my site 
and back to good old client variables too. Still, it would always work 
fine locally but not on WebFaction. After looking Google over and the 
Flask Mailing List, I couldn't find the precise solutions, so after 
figuring it out I thought I would share.

So the fix was something simple, as all of you I'm sure who are well 
weathered with WSGI would know. Naturally after all of this I gathered 
the problem was more than likely not to do with Flask, so I double 
checked my WSGI settings. I'd used the Flask WebFaction guide to set up 
WSGI for Flask, however I'd left the preconfigured settings in there 
also, which was the mistake. The only settings I left in there in the 
end were:
WSGIDaemonProcess

But I added the necessary WSGIScriptAlias setting

When you set up a new WSGI app on WebFaction you get these too:
WSGIProcessGroup
WSGIRestrictEmbedded On
WSGILazyInitialization On

Taking these three out turned out to fix the problem.
Hope this helps someone new like me who MIGHT just be facing the same 
issue, and apologies to those who may be shaking their heads and 
something trivial.

All the best,
Les

Re: [flask] WebFaction and intermittent session variables

From:
Bhavana Bajaj
Date:
2013-02-27 @ 04:09
Hi Les,

Does your solution help with KVSession or did it help with the
alternate approach you used i.e. client variables ?

-Bhavana Bajaj


On Sat, Feb 23, 2013 at 1:44 PM, Leslie Cordell <w0lfm4n@nonapod.org> wrote:
> Hi everyone,
> I wanted to provide a little solution to anyone else fairly new to WSGI
> and Flask like myself. I've already created one medium sized app which I
> put on a personal apache webserver, however after trying to put an app
> on WebFaction, I found my session variables would sometimes be there and
> other times not; logged in on a refresh, not on a few others. I spent
> around 9 hours in total banging my head on this one, I looked into
> cookie size, I even restructured all of my code into one file out of
> curiosity to see if that was the issue, I took KVSession off of my site
> and back to good old client variables too. Still, it would always work
> fine locally but not on WebFaction. After looking Google over and the
> Flask Mailing List, I couldn't find the precise solutions, so after
> figuring it out I thought I would share.
>
> So the fix was something simple, as all of you I'm sure who are well
> weathered with WSGI would know. Naturally after all of this I gathered
> the problem was more than likely not to do with Flask, so I double
> checked my WSGI settings. I'd used the Flask WebFaction guide to set up
> WSGI for Flask, however I'd left the preconfigured settings in there
> also, which was the mistake. The only settings I left in there in the
> end were:
> WSGIDaemonProcess
>
> But I added the necessary WSGIScriptAlias setting
>
> When you set up a new WSGI app on WebFaction you get these too:
> WSGIProcessGroup
> WSGIRestrictEmbedded On
> WSGILazyInitialization On
>
> Taking these three out turned out to fix the problem.
> Hope this helps someone new like me who MIGHT just be facing the same
> issue, and apologies to those who may be shaking their heads and
> something trivial.
>
> All the best,
> Les