session less connections

42 views
Skip to first unread message

icodk

unread,
Sep 26, 2015, 4:47:11 PM9/26/15
to web2py-users
I have many sensors that reports periodically to a web2py application.
The sensors do not need to log in, they just POST a json string to specific controller function, get a few bytes in response and close the connection. However each time a sensor connect, a session file is generated. This create a lot of useless files. Otherwise the site has a standard user interface that requires login from users.
Is it possible  to avoid the session creation just for that controller function or do I need to make a session less app that update the same database ?

Vinicius Assef

unread,
Sep 26, 2015, 9:58:26 PM9/26/15
to web...@googlegroups.com
Read about `sessions.forget()`[1]




Vinicius.




--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
Sep 27, 2015, 9:50:53 AM9/27/15
to web2py-users
No session file should be created unless something is actually written to the session. Are you explicitly writing something to the session anywhere during these requests, or running any code that writes to the session (e.g., processing a form)?

Anthony

Itamar Cohen

unread,
Sep 27, 2015, 10:20:46 AM9/27/15
to web...@googlegroups.com
Thanks Vinicius, it  work for me





Vinicius.




To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/8O6z1tOR2RM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Itamar Cohen

unread,
Sep 27, 2015, 10:28:16 AM9/27/15
to web...@googlegroups.com
No, nothing is write explicitly to the session (as far as I can see), I only save the info to the database and return a string like "{}"
session.forget() looks like  solve the problem.
Thanks.

Best Regards
Itamar Cohen
Picatek
Ahornvej 27
DK-7700 Thisted
Denmark
www.picatek.dk
i...@picatek.dk
T: +45 97 91 07 82
M:+45 29 89 07 82

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/8O6z1tOR2RM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Anthony

unread,
Sep 27, 2015, 2:24:54 PM9/27/15
to web2py-users
On Sunday, September 27, 2015 at 10:28:16 AM UTC-4, icodk wrote:
No, nothing is write explicitly to the session (as far as I can see), I only save the info to the database and return a string like "{}"
session.forget() looks like  solve the problem.

Hmm, something must be writing to the session somewhere, or otherwise session.forget() would make no difference. Without session.forget(), do you see any content in the session after one of these requests?

Anthony

Itamar Cohen

unread,
Sep 27, 2015, 2:51:49 PM9/27/15
to web...@googlegroups.com
I just deleted the  session.forget() and very quickly got a lot of sessions with about 47 bytes

I attached one but I can't make sens of what inside

Best Regards
Itamar Cohen
Picatek
Ahornvej 27
DK-7700 Thisted
Denmark
www.picatek.dk
i...@picatek.dk
T: +45 97 91 07 82
M:+45 29 89 07 82

--
94.191.187.74-09d54085-c698-4f69-add5-dc4ed6f21c0f

Anthony

unread,
Sep 27, 2015, 3:50:20 PM9/27/15
to web2py-users
<Storage {'flash': ''}>

Something is setting session.flash. Does any Auth code run during these requests, or is there any form processing with a redirect?

Anthony




On Sunday, September 27, 2015 at 2:51:49 PM UTC-4, icodk wrote:
I just deleted the  session.forget() and very quickly got a lot of sessions with about 47 bytes

I attached one but I can't make sens of what inside

Best Regards
Itamar Cohen
Picatek
Ahornvej 27
DK-7700 Thisted
Denmark
www.picatek.dk
i...@picatek.dk
T: +45 97 91 07 82
M:+45 29 89 07 82

On 27 September 2015 at 20:24, Anthony wrote:
On Sunday, September 27, 2015 at 10:28:16 AM UTC-4, icodk wrote:
No, nothing is write explicitly to the session (as far as I can see), I only save the info to the database and return a string like "{}"
session.forget() looks like  solve the problem.

Hmm, something must be writing to the session somewhere, or otherwise session.forget() would make no difference. Without session.forget(), do you see any content in the session after one of these requests?

Anthony

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/8O6z1tOR2RM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Itamar Cohen

unread,
Sep 27, 2015, 5:51:50 PM9/27/15
to web...@googlegroups.com
I got these two lines in my model
session.connect(request, response, separate=True)
user_timezone = session.plugin_timezone_tz or 'UTC'
Could this be a reason ?



On 27 September 2015 at 21:50, Anthony <abas...@gmail.com> wrote:
<Storage {'flash': ''}>

Something is setting session.flash. Does any Auth code run during these requests, or is there any form processing with a redirect?

Anthony



On Sunday, September 27, 2015 at 2:51:49 PM UTC-4, icodk wrote:
I just deleted the  session.forget() and very quickly got a lot of sessions with about 47 bytes

I attached one but I can't make sens of what inside

Anthony

unread,
Sep 27, 2015, 7:29:34 PM9/27/15
to web2py-users
No, that code shouldn't set session.flash nor write to the session.


On Sunday, September 27, 2015 at 5:51:50 PM UTC-4, icodk wrote:
I got these two lines in my model
session.connect(request, response, separate=True)
user_timezone = session.plugin_timezone_tz or 'UTC'
Could this be a reason ?

Best Regards
Itamar Cohen
Picatek
Ahornvej 27
DK-7700 Thisted
Denmark
www.picatek.dk
i...@picatek.dk
T: +45 97 91 07 82
M:+45 29 89 07 82

On 27 September 2015 at 21:50, Anthony wrote:
<Storage {'flash': ''}>

Something is setting session.flash. Does any Auth code run during these requests, or is there any form processing with a redirect?

Anthony



On Sunday, September 27, 2015 at 2:51:49 PM UTC-4, icodk wrote:
I just deleted the  session.forget() and very quickly got a lot of sessions with about 47 bytes

I attached one but I can't make sens of what inside
Best Regards
Itamar Cohen
Picatek
Ahornvej 27
DK-7700 Thisted
Denmark
www.picatek.dk
i...@picatek.dk
T: +45 97 91 07 82
M:+45 29 89 07 82

Itamar Cohen

unread,
Sep 28, 2015, 3:37:12 AM9/28/15
to web...@googlegroups.com
I found this line close to the top of  my default.py
session.flash=response.flash
Could be it ?


On 28 September 2015 at 01:29, Anthony <abas...@gmail.com> wrote:
No, that code shouldn't set session.flash nor write to the session.

On Sunday, September 27, 2015 at 5:51:50 PM UTC-4, icodk wrote:
I got these two lines in my model
session.connect(request, response, separate=True)
user_timezone = session.plugin_timezone_tz or 'UTC'
Could this be a reason ?

On 27 September 2015 at 21:50, Anthony wrote:
<Storage {'flash': ''}>

Something is setting session.flash. Does any Auth code run during these requests, or is there any form processing with a redirect?

Anthony



On Sunday, September 27, 2015 at 2:51:49 PM UTC-4, icodk wrote:
I just deleted the  session.forget() and very quickly got a lot of sessions with about 47 bytes

I attached one but I can't make sens of what inside
Reply all
Reply to author
Forward
0 new messages