Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load values not updating on turbo.push() call #44

Closed
BigBuckHunter opened this issue Oct 27, 2022 · 5 comments
Closed

Load values not updating on turbo.push() call #44

BigBuckHunter opened this issue Oct 27, 2022 · 5 comments

Comments

@BigBuckHunter
Copy link

BigBuckHunter commented Oct 27, 2022

I have cloned this repo, installed flask/turbo-flask, and run flask run in examples/load. I then visit 127.0.0.1:5000 and the page displays as expected, but the Load averages values do not update every 5 seconds like they should. If I click the link back and forth between Page 2 and Page 1, the values update.

I have no error messages in my logs. I added debug statements to inject_load() and right before turbo.push(turbo.replace(render_template('loadavg.html'), 'load')), and I can confirm that my update_load() loop is running successfully.

What am I missing? I can provide screen recording if helpful.

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Oct 27, 2022

Are you using the last released version of turbo-flask? Try version 0.8.0, there is currently an issue with the turbo.js CDN. Downgrading is the workaround.

Reference: #42

@BigBuckHunter
Copy link
Author

That solved it, thank you!

@BigBuckHunter
Copy link
Author

The downgrade to 0.8.0 was successful when running locally on the dev server.

I have since attempted to deploy my application to production following the steps outlined here.

After completing the tutorial above, I am now in the same position as before. Visiting my URL loads the initial page, but turbo.push(turbo.replace(...)) has no effect. I have turbo-flask version 0.8.0 installed.

This is the first web application I have ever developed, and I'm a bit out of my depth here. I suspect that the issue is with the way I have configured gunicorn or nginx. Is there any documentation you can point me to for using gunicorn and turbo-flask together successfully? I have looked at the flask-sock documentation as suggested in the readme, but that hasn't solved my issue.

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Nov 3, 2022

@BigBuckHunter You need to look at the console in your browser and your server logs for clues. If I had to guess, I would say that the problem is likely that you did not properly configure WebSocket in your nginx configuration. The turbo.js library makes a call to the /turbo-stream endpoint using WebSocket.

Unfortunately nginx does not automatically proxy WS endpoints. There's a ton of tutorials on how to configure WS out there, for example: https://www.nginx.com/blog/websocket-nginx/.

@miguelgrinberg
Copy link
Owner

@BigBuckHunter I have expanded the Deployment section of the docs with an Nginx example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants