Comments (10)
I have not used this with MySQL (I'm using Postgres for my projects), and I don't have this problem with postgres.
Any more information you can give me so I can try to replicate this?
I will setup a test project with MySQL and see if I get this issue.
from swampdragon.
I've created a demo project running a celery task every 2 second updating a self publishing model.
I have five browsers open viewing the page that receives the updates.
So far I have not seen any issues with MySQL but I'll leave it running for a while.
from swampdragon.
Thanks for trying to re-create my issue. It seems like my MySQL server is running into a connection limit and randomly aborts connections. I get tons of the following errors:
[Warning] Aborted connection $n to db: '$dbname' user: '$user' host: '$host' (Unknown error)
Let me check if I can increase that limit.
from swampdragon.
Okay, got it. The MySQL wait_timeout parameter was set too low. 600 seconds is not enough for the SwampDragon server. Does it perform any kind of heartbeat operation to keep the database connection open?
from swampdragon.
Currently it doesn't. I would like to know how to replicate this issue.
I'm not overly familiar with MySQL. I set the timeout to a low number but I'm still not getting a timeout.
Could you describe your setup so I can tweak my test project to be more similar (and hopefully get the same issue so I can solve it)?
from swampdragon.
It seems like increasing wait_time only delays the problem. Here is the my.cnf used for mariadb-server (10.0.13+maria-1~wheezy) and the relevant environment-specific Django config: https://gist.github.com/mback2k/899fced7241f64b50793. The remaining Django config can be found here: https://github.com/mback2k/django-webgcal/tree/master/webgcal/settings.
You said that your celery task actually performs something in the background, so the database connection is actually used. What happens if you disable that task, just connect to the WebSocket once to get some data and then close your browser until wait_timeout is hit? Thanks for investigating this.
from swampdragon.
I've managed to replicate this issue now (thanks for the settings).
It doesn't happen when running with Postgres (and SQLite) which are the only databases I've tried until now.
It wasn't until I added
'OPTIONS': {
'init_command': 'SET storage_engine=INNODB',
}
to settings that this started happening.
I've created a gist for this for now until I figure out what to do in the long run:
https://gist.github.com/jonashagstedt/6113b0e0e9cd4b4c3585
Let me know if that solves the problem.
I've tested this by setting the timeout to a very low number and it works.
Remember to update the connection in settings:
SWAMP_DRAGON_CONNECTION = ('myproject.connection.MysqlHeartbeatConnection', '/data')
from swampdragon.
I ran a very simple test to make sure there wasn't a significant performance loss with this solution (and there wasn't).
The test is very simple and does the following:
- Connect 300 clients
- Subscribe to a channel
- Get a list of models
With the gist provided above, I ran the test five times:
631 ms
624 ms
642 ms
642 ms
616 ms
avg: 631 ms
With the default connection:
639 ms
632 ms
642 ms
641 ms
653 ms
avg: 641 ms
from swampdragon.
Thanks for providing this workaround. I verified that it also solves the problem for me. I also tried to alternatively set CONN_MAX_AGE to something below wait_timeout, but that alone didn't help. Maybe you want to include that heartbeat into the default connection and make it detect MySQL like this:
if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql':
from swampdragon.
I've thought about it for a bit now and it would be clever to check the DB engine, however the timeout is posing a bit of a problem.
Since the timeout of MySql can differ from environments it's something that needs to be set by the user.
I wrote up a short blog post about it (http://swampdragon.net/blog/mysql-server-has-gone-away/) instead.
Good suggestion though
from swampdragon.
Related Issues (20)
- how to implement swampdragon properly
- ERROR:tornado.general:WebSocket ... DoesNotExist: TodoList matching query does not exist.
- Settings.js HOT 3
- Synchronize Swampdragon in django cluster
- [frontend] How to handle arriving messages published to concrete channel HOT 6
- 0.4.2.2 issues w/ tutorial psutil HOT 7
- Todo tutorial - route not found HOT 2
- Idea: add template tag to make template parts update in realtime HOT 7
- has_related_value HOT 1
- Release version does not work with Django1.9 HOT 3
- settings.js not found HOT 2
- unit test does not support for auth
- How to avoid 'false' SwampDragon messages
- takeover
- Site can't be reached!? HOT 6
- Connection Swampdragon to a Redis Socket HOT 1
- About swampdragon.net HOT 1
- swampdragon.net site is down HOT 1
- I will to take this site maintanance and also to update it
- Private chat implementation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swampdragon.