web2py / py4web

Other
247 stars 126 forks source link

Pythonanywhere issue #288

Closed duskmaiden18 closed 3 years ago

duskmaiden18 commented 4 years ago

Hello. I have deployed my py4web app on the Pythonanywhere, and I have some problems with registration. When I want to register, nothing happens and this error appears in the console. What can be wrong? I also deployed myfeed app and there is the same problem. Capture

mdipierro commented 4 years ago

Sorry. Not enough information.

Can you check for logs on python anywhere? What py4web version? Is this on first installation or after upgrade ot py4web?

On Mon, Sep 14, 2020 at 8:33 AM duskmaiden18 notifications@github.com wrote:

Hello. I have deployed my py4web app on the Pythonanywhere, and I have some problems with registration. When I want to register, nothing happens and this error appears in the console. What can be wrong? I also deployed myfeed app and there is the same problem. [image: Capture] https://user-images.githubusercontent.com/46170546/93106065-7c6aa280-f6b8-11ea-8975-c07336adcf75.PNG

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/web2py/py4web/issues/288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHLZT6TIINTPEEBTNCCN6LSFYZSXANCNFSM4RLX4DCQ .

duskmaiden18 commented 4 years ago

Well, I think that problem is not in the Pythoanywhere. It is most likely appeared because of versions mismatch, because previosly I didnt check it at my localhost. I have download the newest version of py4web from github to my computer, then insert to path "apps" my app, that has version py4web==0.1.20200202.1, and registration doesnt also work on my localhost(401 error). How can I solve it?

nicozanf commented 4 years ago

Hi,

your description is not so clear for me ... How have you installed py4web on Pythonanywhere? There is a detailed tutorial here https://github.com/tomcam/py4webcasts/blob/master/docs/how-install-source-pythonanywhere.md (thank you, Tom). How have you installed py4web on your computer? The official instructions are here https://py4web.com/_documentation/static/index.html#chapter-01. What's its OS?

Also, it's not a good habit to copy pieces of python programs to different systems. They could contain compiled objects that are not compatible with different OS or different python versions.

Probably the simplest solution is to start from scratch....

Nico

Il giorno lun 14 set 2020 alle ore 21:23 duskmaiden18 < notifications@github.com> ha scritto:

Well, I think that problem is not in the Pythoanywhere. It is most likely appeared because of versions mismatch, because previosly I didnt check it at my localhost. I have download the newest version of py4web from github to my computer, then insert to path "apps" my app, that has version py4web==0.1.20200202.1, and registration doesnt also work on my localhost(401 error). How can I solve it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/web2py/py4web/issues/288#issuecomment-692262260, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARL3BYEJFN5Y63TDEHWINLSFZUSFANCNFSM4RLX4DCQ .

duskmaiden18 commented 4 years ago

Ok,thank you

duskmaiden18 commented 4 years ago

Hi, your description is not so clear for me ... How have you installed py4web on Pythonanywhere? There is a detailed tutorial here https://github.com/tomcam/py4webcasts/blob/master/docs/how-install-source-pythonanywhere.md (thank you, Tom). How have you installed py4web on your computer? The official instructions are here https://py4web.com/_documentation/static/index.html#chapter-01. What's its OS? Also, it's not a good habit to copy pieces of python programs to different systems. They could contain compiled objects that are not compatible with different OS or different python versions. Probably the simplest solution is to start from scratch.... Nico Il giorno lun 14 set 2020 alle ore 21:23 duskmaiden18 < notifications@github.com> ha scritto: Well, I think that problem is not in the Pythoanywhere. It is most likely appeared because of versions mismatch, because previosly I didnt check it at my localhost. I have download the newest version of py4web from github to my computer, then insert to path "apps" my app, that has version py4web==0.1.20200202.1, and registration doesnt also work on my localhost(401 error). How can I solve it? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#288 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARL3BYEJFN5Y63TDEHWINLSFZUSFANCNFSM4RLX4DCQ .

I start my app from scratch and registration works at localhost. Then I deployed it to pythonanywhere using tutorial that you gave me. And registration works only when "VERIFY_EMAIL" is False. When I change it to True, and try to register, in the DevTool in the Network tab appears a registration request that is pending, and then 504 error(gateway time-out). Capture1 Capture3 Here my setting for verifying email: Capture2 Also I allowed (in the account settings) external apps to use my gmail account

duskmaiden18 commented 4 years ago

This is server.log, but there are nothing about this situation as I can see: 2020-09-15 11:44:07 announcing my loyalty to the Emperor... 2020-09-15 11:44:23 Tue Sep 15 11:44:23 2020 - received message 0 from emperor 2020-09-15 11:44:23 SIGINT/SIGQUIT received...killing workers... 2020-09-15 11:44:24 worker 1 buried after 1 seconds 2020-09-15 11:44:24 goodbye to uWSGI. 2020-09-15 11:44:24 chdir(): No such file or directory [core/uwsgi.c line 1610] 2020-09-15 11:44:24 VACUUM: unix socket /var/sockets/testforme2020.pythonanywhere.com/socket removed. 2020-09-15 11:44:29 Starting uWSGI 2.0.17.1 (64bit) on [Tue Sep 15 11:44:25 2020] 2020-09-15 11:44:29 compiled with version: 5.4.0 20160609 on 07 May 2020 19:40:56 2020-09-15 11:44:29 os: Linux-4.4.0-1106-aws #117 SMP Thu May 7 18:33:20 UTC 2020 2020-09-15 11:44:29 nodename: green-liveweb9 2020-09-15 11:44:29 machine: x86_64 2020-09-15 11:44:29 clock source: unix 2020-09-15 11:44:29 pcre jit disabled 2020-09-15 11:44:29 detected number of CPU cores: 2 2020-09-15 11:44:29 current working directory: (unreachable)/etc/uwsgi/vassals 2020-09-15 11:44:29 detected binary path: /usr/local/bin/uwsgi 2020-09-15 11:44:29 dumping internal routing table 2020-09-15 11:44:29 [rule: 0] subject: path_info regexp: .svgz$ action: addheader:Content-Encoding:gzip 2020-09-15 11:44:29 end of the internal routing table 2020-09-15 11:44:29 chdir() to /home/testforme2020/py4web 2020-09-15 11:44:29 limiting number of processes to 60... 2020-09-15 11:44:29 your processes number limit is 60 2020-09-15 11:44:29 your memory page size is 4096 bytes 2020-09-15 11:44:29 detected max file descriptor number: 123456 2020-09-15 11:44:29 building mime-types dictionary from file /etc/mime.types... 2020-09-15 11:44:29 552 entry found 2020-09-15 11:44:29 lock engine: pthread robust mutexes 2020-09-15 11:44:29 thunder lock: disabled (you can enable it with --thunder-lock) 2020-09-15 11:44:29 uwsgi socket 0 bound to UNIX address /var/sockets/testforme2020.pythonanywhere.com/socket fd 3 2020-09-15 11:44:29 Python version: 3.8.0 (default, Nov 14 2019, 22:29:45) [GCC 5.4.0 20160609] 2020-09-15 11:44:29 Python threads support is disabled. You can enable it with --enable-threads 2020-09-15 11:44:29 Python main interpreter initialized at 0x221a5e0 2020-09-15 11:44:29 your server socket listen backlog is limited to 100 connections 2020-09-15 11:44:29 your mercy for graceful operations on workers is 60 seconds 2020-09-15 11:44:29 setting request body buffering size to 65536 bytes 2020-09-15 11:44:29 mapped 334256 bytes (326 KB) for 1 cores 2020-09-15 11:44:29 Operational MODE: single process 2020-09-15 11:44:29 initialized 38 metrics 2020-09-15 11:44:29 [ ] loading _scaffold ... 2020-09-15 11:44:29 #033[A[X] loaded _scaffold
2020-09-15 11:44:29 [ ] loading _default ... 2020-09-15 11:44:29 #033[A[X] loaded _default
2020-09-15 11:44:29 [ ] loading _minimal ... 2020-09-15 11:44:29 #033[A[X] loaded _minimal
2020-09-15 11:44:29 [ ] loading todo ... 2020-09-15 11:44:29 #033[A[X] loaded todo
2020-09-15 11:44:29 [ ] loading _dashboard ... 2020-09-15 11:44:29 #033[A[X] loaded _dashboard
2020-09-15 11:44:29 [ ] loading examples ... 2020-09-15 11:44:29 #033[A[X] loaded examples
2020-09-15 11:44:29 [ ] loading _documentation ... 2020-09-15 11:44:29 #033[A[X] loaded _documentation
2020-09-15 11:44:29 [ ] loading strahovka ... 2020-09-15 11:44:29 #033[A[X] loaded strahovka
2020-09-15 11:44:29 [ ] loading myfeed ... 2020-09-15 11:44:29 #033[A[X] loaded myfeed
2020-09-15 11:44:29 WSGI app 0 (mountpoint='') ready in 4 seconds on interpreter 0x221a5e0 pid: 1 (default app) 2020-09-15 11:44:29 uWSGI is running in multiple interpreter mode 2020-09-15 11:44:29 gracefully (RE)spawned uWSGI master process (pid: 1) 2020-09-15 11:44:29 spawned uWSGI worker 1 (pid: 5, cores: 1) 2020-09-15 11:44:29 metrics collector thread started 2020-09-15 11:44:29 spawned 2 offload threads for uWSGI worker 1 2020-09-15 11:44:53 3 2020-09-15 11:44:53 announcing my loyalty to the Emperor...

nicozanf commented 4 years ago

Hi,

did you ever succeed in sending SMTP emails from Pythonanywhere? It could be that Google is blocking your attempt for security reason.

Test it with a Bash prompt in Pythonanywere. Follow this post for connecting to port 587 directly with TLS. If you've got "Username and Password not accepted. " it means that you need to enable "Access for less secure apps" in your Google account (which seems you've already done). I was getting the "Please log in via your web browser and then try again." until I visit this page for unlocking it http://www.google.com/accounts/DisplayUnlockCaptcha. See here for more details. NOTE: if you use the same browser with multiple Google accounts be careful to use a new incognito session with the account used to send SMTP, otherwise the last setting could be applied to another account.

If you' are able to send SMTP mail from Pythonanywhere, we'll have to look to py4web ...

mdipierro commented 4 years ago

That may require a paying account from pythonanywhere.

On Tue, Sep 15, 2020 at 1:32 PM Nico Zanferrari notifications@github.com wrote:

Hi,

did you ever succeed in sending SMTP emails from Pythonanywhere? It could be that Google is blocking your attempt for security reason.

Test it with a Bash prompt in Pythonanywere. Follow this post https://stackoverflow.com/a/11049483 for connecting to port 587 directly with TLS. If you've got "Username and Password not accepted. " it means that you need to enable "Access for less secure apps" in your Google account (which seems you've already done). I was getting the "Please log in via your web browser and then try again." until I visit this page for unlocking it http://www.google.com/accounts/DisplayUnlockCaptcha. See here https://stackoverflow.com/a/25238515 for more details. NOTE: if you use the same browser with multiple Google accounts be careful to use a new incognito session with the account used to send SMTP, otherwise the last setting could be applied to another account.

If you' are able to send SMTP mail from Pythonanywhere, we'll have to look to py4web ...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/web2py/py4web/issues/288#issuecomment-692963122, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHLZTZN4E4E6N74E2JXLGLSF7FPVANCNFSM4RLX4DCQ .

nicozanf commented 4 years ago

I'm quite sure I can send Google SMTP email using command line from a free PythonAnywhere account ;-)

mdipierro commented 4 years ago

My understanding is that free accounts do not allow outbound connections. Maybe there are exceptions.

On Tue, Sep 15, 2020 at 3:38 PM Nico Zanferrari notifications@github.com wrote:

I'm quite sure I can send Google SMTP email using command line from a free PythonAnywhere account ;-)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/web2py/py4web/issues/288#issuecomment-693016068, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHLZTYTTP32IWFQGMGH7MDSF7UEXANCNFSM4RLX4DCQ .

duskmaiden18 commented 4 years ago

Hi,

did you ever succeed in sending SMTP emails from Pythonanywhere? It could be that Google is blocking your attempt for security reason.

Test it with a Bash prompt in Pythonanywere. Follow this post for connecting to port 587 directly with TLS. If you've got "Username and Password not accepted. " it means that you need to enable "Access for less secure apps" in your Google account (which seems you've already done). I was getting the "Please log in via your web browser and then try again." until I visit this page for unlocking it http://www.google.com/accounts/DisplayUnlockCaptcha. See here for more details. NOTE: if you use the same browser with multiple Google accounts be careful to use a new incognito session with the account used to send SMTP, otherwise the last setting could be applied to another account.

If you' are able to send SMTP mail from Pythonanywhere, we'll have to look to py4web ...

I did what you say, here is screenshot that SMTP emails work(I have recieved mail from strahovka.work2020@gmail.com on zikzak200015@gmail.com) SMTP

Then I re-run py4web apps, reload site and registration stiil not working(

duskmaiden18 commented 4 years ago

image

duskmaiden18 commented 4 years ago

Hi,

did you ever succeed in sending SMTP emails from Pythonanywhere? It could be that Google is blocking your attempt for security reason.

Test it with a Bash prompt in Pythonanywere. Follow this post for connecting to port 587 directly with TLS. If you've got "Username and Password not accepted. " it means that you need to enable "Access for less secure apps" in your Google account (which seems you've already done). I was getting the "Please log in via your web browser and then try again." until I visit this page for unlocking it http://www.google.com/accounts/DisplayUnlockCaptcha. See here for more details. NOTE: if you use the same browser with multiple Google accounts be careful to use a new incognito session with the account used to send SMTP, otherwise the last setting could be applied to another account.

If you' are able to send SMTP mail from Pythonanywhere, we'll have to look to py4web ...

I just find out another problem with SMTP on my website. I have ajax on the page, it call function from controllers.py. This is code of the function:

@action("static/add_company", method="POST") @action.uses("add_company.html", db) def add(): logger.info('Add method started') db_obj = DatabaseAccess() print("XXX") last_company = db(db.company).select().last() print("YYY") last_data = last_company.update_date print(last_data) rows = db(db.company.update_date == last_data).select() choice_id = request.POST.get('choice_id') print(choice_id) action = request.POST.get('action') current_company = db(db.company.id == choice_id).select().last() user_id = my_auth.get_user()['id'] print(user_id) admin = db(db.site_user.auth_user == user_id).select().first().admin site_user = db_obj.get_user(user_id) auth_user = db_obj.get_auth_user(user_id) print(auth_user) fromaddr = 'strahovka.work2020@gmail.com' toaddr = auth_user.email

toaddr = current_company.email

username = 'strahovka.work2020@gmail.com'
password = ------------
server = smtplib.SMTP('smtp.gmail.com:587')

This code executes till this line "server = smtplib.SMTP('smtp.gmail.com:587')" , then it stops and thats all. But in the server.log there are messages: 2020-09-16 15:51:39 Wed Sep 16 15:51:38 2020 - HARAKIRI ON WORKER 1 (pid: 5, try: 1) 2020-09-16 15:51:39 Wed Sep 16 15:51:38 2020 - HARAKIRI !!! worker 1 status !!! 2020-09-16 15:51:39 Wed Sep 16 15:51:38 2020 - HARAKIRI [core 0] 10.0.0.52 - POST /strahovka/static/add_company since 1600270897 2020-09-16 15:51:39 Wed Sep 16 15:51:38 2020 - HARAKIRI !!! end of worker 1 status !!!

nicozanf commented 4 years ago

Hi,

I confirm the issue.

With the same parameters on settings.py, it works on Windows with Py 3.7, and the latest Ubuntu on VirtualBox with Py 3.8. But on PythonAnywhere it gets stuck without errors after compiling the registration form. All Py4web becames stuck and is not possible to use any related app. Using 'logging' as the SMTP server allows to submit the registration form. Then, using the token url from logs, is possible to confirm email and then logging inside.

Kkeller83 commented 3 years ago

I would open a ticket on pythonanywhere for this

nicozanf commented 3 years ago

I've written in their forum here https://www.pythonanywhere.com/forums/topic/168/#id_post_85479. In fact, Google SMTP services should work for free users, too (see here https://help.pythonanywhere.com/pages/SMTPForFreeUsers/).

Nico

Il giorno dom 27 set 2020 alle ore 02:17 Kkeller83 notifications@github.com ha scritto:

I would open a ticket on pythonanywhere for this

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/web2py/py4web/issues/288#issuecomment-699564038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARL3B4BDHI4PYN2BOYMIMLSH2AA3ANCNFSM4RLX4DCQ .

nicozanf commented 3 years ago

I think it's related to this discussion. In fact, it seems a py4web issue (only on PythonAnywhere).

mdipierro commented 3 years ago

I am in contact with Giles at PythonAnywhere and he wants to help make it as simple as possible to use py4web on python anywhere. Tomorrow we should brainstorm what we want to ask.

Massimo

On Oct 2, 2020, at 2:33 PM, Nico Zanferrari notifications@github.com wrote:

I think it's related to this discussion https://groups.google.com/d/msgid/py4web/21718b9b-fdfc-49bc-8573-8712fd20095an%40googlegroups.com?utm_medium=email&utm_source=footer. In fact, it seems a py4web issue (only on PythonAnywhere).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/web2py/py4web/issues/288#issuecomment-702967818, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHLZTYVATDB7GMJTUBX2ULSIZBKHANCNFSM4RLX4DCQ.

nicozanf commented 3 years ago

Hi, this issue can be solved by removing gevent completely (as it's done on the current py4web version), see here.

I think we can close the issue.