how to execute web2py with Rocket using SSL?

137 views
Skip to first unread message

VJ Sosa

unread,
Apr 23, 2020, 8:55:21 AM4/23/20
to web2py-users
Hello Everyone,

Maybe this is a silly question, but I run web2py using the following command:

python3 web2py.py -i 0.0.0.0 -p 8080 --nogui -a 'Password'

Everything goes well. My application is working . My application includes an authentication part,
and so far it is running on HTTP, so browsers warns me about I'm using an insecure conexion . I was ignoring those messages so far..

However,  i would like to activate the SSL conexion in the Rocket server.
I tried to execute web2py using the following command:

python3 web2py.py -c web2py.crt -k web2py.key -i 0.0.0.0 -p 8080 --nogui -a 'Password'

It runs, but when I try to connect to the server (my app) using my browser:
xx.xx.xx.xx:8080/myapp

The browser (Chrome) tells me that it is not possible to connect to the site.
And the server part shows a list of errors, I'm including some of them:
<<<<
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/vsosa/Applications/web2py/gluon/rocket.py", line 1268, in run
    conn = Connection(*conn)
  File "/home/vsosa/Applications/web2py/gluon/rocket.py", line 105, in __init__
    self.socket.settimeout(SOCKET_TIMEOUT)
OSError: [Errno 9] Bad file descriptor

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/vsosa/Applications/web2py/gluon/rocket.py", line 1268, in run
    conn = Connection(*conn)
  File "/home/vsosa/Applications/web2py/gluon/rocket.py", line 105, in __init__
    self.socket.settimeout(SOCKET_TIMEOUT)
OSError: [Errno 9] Bad file descriptor

<<<

am I missing something?
is this the right way to execute web2py on Rocket using SSL:

python3 web2py.py -c web2py.crt -k web2py.key -i 0.0.0.0 -p 8080 --nogui -a 'Password'

Thank you in advance.

Best regards,
Víctor




VJ Sosa

unread,
Apr 23, 2020, 12:12:02 PM4/23/20
to web2py-users
I have tried the same command, running web2py with python 2.7.17 and it works:

python web2py.py -c web2py.crt -k web2py.key -i 0.0.0.0 -p 8080 --nogui -a 'Password'


The problem occurs when running web2py with  python3.
I found the same discussion in this link < here >, but it seems that the error still persists.
Any help? 

Regards,
Víctor.

Jim S

unread,
Apr 23, 2020, 1:05:17 PM4/23/20
to web2py-users
What is your version of web2py?

-Jim

VJ Sosa

unread,
Apr 23, 2020, 2:03:22 PM4/23/20
to web2py-users
Hi,

Thanks for asking:

Web2py Version 2.18.5-stable+timestamp.2019.04.08.04.22.03

Python version: 3.6.9

Regards,
Víctor

Jim S

unread,
Apr 23, 2020, 4:24:36 PM4/23/20
to web2py-users
VJ

I just ran a test and can confirm I'm getting the same results as you.

I just cloned the latest web2py from git.

I ran under Python 2.7 and it worked fine.
Running under Python 3.7 and I get results like you.

To do a little debugging, I put a print statement ahead of line 105 in gluon/rocket.py -> print('socket_tuple', socket_tuple)  I get the following:

Python 2.7
('sock_tuple', (<socket._socketobject object at 0x7f09d9a4eb40>, ('127.0.0.1', 32984)))
('sock_tuple', (<ssl.SSLSocket object at 0x7f09d91f20d0>, ('127.0.0.1', 32986)))
('sock_tuple', (<socket._socketobject object at 0x7f09d9a4ed70>, ('127.0.0.1', 32988)))
('sock_tuple', (<socket._socketobject object at 0x7f09c84ee750>, ('127.0.0.1', 32990)))
('sock_tuple', (<ssl.SSLSocket object at 0x7f09c84ec5d0>, ('127.0.0.1', 32992)))
('sock_tuple', (<ssl.SSLSocket object at 0x7f09c84ec350>, ('127.0.0.1', 32994)))

Python 3.7
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33048))
sock_tuple
(<ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 8000), raddr=('127.0.0.1', 33050)>, ('127.0.0.1', 33050))
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33052))
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33054))
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33056))
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33058))
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33062))
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33064))
sock_tuple
(<ssl.SSLSocket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 8000), raddr=('127.0.0.1', 33066)>, ('127.0.0.1', 33066))
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33068))
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33070))
sock_tuple
(<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, ('127.0.0.1', 33072))

I don't know what's going on, but can confirm that this isn't fixed.

-Jim

Clemens

unread,
Apr 24, 2020, 3:57:16 AM4/24/20
to web2py-users
Hello,

it seems that there are some problems with rocket under Python 3.x. As posted a few weeks ago I have the following problem:

I've switched my web2py app from python2 to python3. The app itself works fine, but the web2py online debugger doesn't work anymore and is mostly freezing. Sometimes a get the following error message:

Exception timeout: timeout('timed out',)

Traceback (most recent call last): File "/usr/lib/python3.6/socket.py", line 586, in readinto return self._sock.recv_into(b) socket.timeout: timed out

My configuration is as follows:

web2py 2.19.1-stable+timestamp.2020.03.21.21.49.28 (Running on Rocket 1.2.6, Python 3.6.9), Ubuntu 18.04 LTS

Do you have this problem too? Since this problem also depends on sockets, maybe this is a hint to a solution for "your" problem mentioned here. Of course I hope the solution would solve "my" problem too.

In the meantime I've established short script switching between Python 2.x and 3.x. Means, using Python3 as long as I don't have to use the debugger and switching to Python 2 if required. The script is running under Linux. Any interest?


Best regards

Clemens



VJ Sosa

unread,
Apr 24, 2020, 7:00:41 AM4/24/20
to web2py-users
Hi Jim and Clemen,

I really appreciate your support and time.
I'm newbie in python programming, so my idea was to have an easy implementation of my wepapp using web2py + Rocket (it was an excelent option for me until this issue with Rocket arised). 
So, I have decided to leave Rocket out of the equation and try to  move into the Apache or Nginx configuration, which implies to include  a little more stuff, 
so I hope to be able of migrating my webapp soon.

Just in case,  if you found any solution for this Rocket issue with Python 3 in web2py, it will be welcome. I'm  still convinced that Web2py + Rocket is the best option for faster development of webapps in Python.

Regards,
Víctor.

Jim S

unread,
Apr 24, 2020, 8:41:05 AM4/24/20
to web2py-users
VJ

I agree web2py + rocket is a good way to go about this.

But, in the documentation I believe it is recommended to not use Rocket for a production server.  If running on linux I believe nginx is the best place choice for a web server.  Yes, it is more complicated to setup, but in th end you're going to have a more reliable web stack.

That being said, I have 3 production servers running my app.  One uses nginx (Server A) and the other 2 (Servers B and C) use Rocket.  However, I front-end servers B and C with haproxy to load balance between the two running rocket.  I don't know what the issue is, but at least every few days I have to restart servers B and C because they lock up.  I haven't been able to find any messages when this happens so I haven't been able to trouble-shoot yet.  My plans are to rebuild these servers with nginx instead of rocket.

TLDR;

Rocket is great for development work, but I'd recommend using nginx in a production environment based on the recommendation in the book and on my own experience.

-Jim

VJ Sosa

unread,
Apr 24, 2020, 11:20:42 AM4/24/20
to web...@googlegroups.com
  Thanks Jim,

I will follow your advice on using Nginx. 
However, it is not quite intuitive the way this configuration is explained in the web2py book. Details are given for the  Apache2 configuration.
It is assumed that the reader has enough knowledge on how to configure a web server.
Could your recommend an step-by-step tutorial (Web2py + nginx configuration for dummies), especially where secure configuration is activated (HTTPS).

Best regards,
Víctor.
 

--
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/BFvo2tn9IAI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/5a7b2319-d11b-49a7-b3df-e969d20744af%40googlegroups.com.


--
Victor J. Sosa Sosa

Jim S

unread,
Apr 24, 2020, 11:28:18 AM4/24/20
to web2py-users
There is a script available to do the nginx install on Ubuntu, but I haven't looked at it in a while.  When I went through it there were changes that were needed for me to get it working.  But, that was back pre-Ubuntu 16, so the script has changed to allow for systemd instead of upstart.  In the coming weeks I plan to get in to it to replace my rocket servers with nginx.  From my view, nginx is way easier to configure than apache. 

Here is the script:


-Jim
To unsubscribe from this group and all its topics, send an email to web...@googlegroups.com.

Clemens

unread,
Apr 24, 2020, 11:28:22 AM4/24/20
to web2py-users
Victor,

I've written my personal step-by-step deployment guide for web2py and Nginx which I'm using for my production system. If interested, I can send you as a PDF document.

But what I couldn't realize is to use the web2py-Nginx-enviroment for debugging. As long only for production it's fine for me but not for development.

Thus, I still hope there will be a solution for the rocket-socket-prob.

Best regards
Clemens
To unsubscribe from this group and all its topics, send an email to web...@googlegroups.com.

Jim S

unread,
Apr 24, 2020, 11:44:40 AM4/24/20
to web2py-users
Clemens

Can you share that PDF with all of us when you have it complete?

-Jim

Clemens

unread,
Apr 24, 2020, 12:03:03 PM4/24/20
to web2py-users
Sure! But now I have to make fire for the kids and their stick breads :-) I will clean up my notes on Sunday and send here.

Have a nice weekend!

VJ Sosa

unread,
Apr 24, 2020, 2:15:08 PM4/24/20
to web...@googlegroups.com
Thank you Jim,

I'll take a look at that script.
Regards,
Víctor

To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/c5d55eed-22fe-44eb-b3dc-e69ea74afca5%40googlegroups.com.

VJ Sosa

unread,
Apr 24, 2020, 2:19:10 PM4/24/20
to web...@googlegroups.com
Thanks Clemens,

I have a similar work to do right now :-)
For sure , your pdf manual will be very helpful for me.  Please send it when you can.
Regards,
Víctor

To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/beca97e5-e7d0-4016-a772-a681a62c6052%40googlegroups.com.

Clemens

unread,
Apr 26, 2020, 9:54:13 AM4/26/20
to web2py-users
Attached please find the PDF document.

Best regards
Clemens


On Friday, April 24, 2020 at 8:19:10 PM UTC+2, VJ Sosa wrote:
Thanks Clemens,

I have a similar work to do right now :-)
For sure , your pdf manual will be very helpful for me.  Please send it when you can.
Regards,
Víctor

web2py+nginx+postgres.pdf

Jim Steil

unread,
Apr 26, 2020, 10:30:36 AM4/26/20
to web...@googlegroups.com
Clemens

Thank you for this.  I hope to get to reinstalling my servers this week and will use this and the web2py document as a base.  FWIW, my goal will be to build an Ansible playbook for my install.

Thanks again and enjoy the rest of the weekend.  It's a beautiful day here in Wisconsin!

-Jim


To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/e6b26fd1-a47d-4d65-bc7f-d78a3e21b4be%40googlegroups.com.

Clemens

unread,
Apr 26, 2020, 10:50:21 AM4/26/20
to web2py-users
Jim,

have a try. In case you have any questions, please let me know. I can set up a cloud server as a kind of training environment, thus we can use for instructional purpose. To evaluate the cleaned-up description I've done this today - 10min for the server to run.

Enjoy your beautiful day in Wisconsin! I will do the same on this sunny day in Germany.

Clemens


On Sunday, April 26, 2020 at 4:30:36 PM UTC+2, Jim S wrote:
Clemens

Thank you for this.  I hope to get to reinstalling my servers this week and will use this and the web2py document as a base.  FWIW, my goal will be to build an Ansible playbook for my install.

Thanks again and enjoy the rest of the weekend.  It's a beautiful day here in Wisconsin!

-Jim


VJ Sosa

unread,
Apr 27, 2020, 6:36:32 AM4/27/20
to web...@googlegroups.com
Dear Clemens,

Thank you for this guide.  It looks great, I will try later today.
Greetings from a small place in Castilla La Mancha, Spain.

Have a nice week,
Víctor

To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/e6b26fd1-a47d-4d65-bc7f-d78a3e21b4be%40googlegroups.com.

Jim S

unread,
Apr 29, 2020, 10:49:31 PM4/29/20
to web2py-users
Anyone else using Ansible for managing servers?  I am just getting started with it and wrote up a couple playbooks to install web2py on Ubuntu 20.04 using Python 3 or Python 2.


I started a github repo with what I have so far.  It is working for me with both Python 2 and Python 3 on Ubuntu 20.04.

Thanks to Clemens for the document you shared this weekend and thanks to Paolo for the set-web2py-nginx-uwsgi-ubuntu.sh script shared in the web2py scripts directory.

Please share any comments so we can improve.

-Jim

On Monday, April 27, 2020 at 5:36:32 AM UTC-5, VJ Sosa wrote:
Dear Clemens,

Thank you for this guide.  It looks great, I will try later today.
Greetings from a small place in Castilla La Mancha, Spain.

Have a nice week,
Víctor

Reply all
Reply to author
Forward
0 new messages