I have a django+mysql website on AWS.
Client send post request to website, then the website query the mysql database and return a json.
I am doing stress testing to it.
I send 300 post requests simultaneously to the website and get responses correctly.
But if I increase the number of post request to 400, it fails with following log.
Server side :
File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run
self.finish_response()
File "/usr/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response
self.write(data)
File "/usr/lib/python2.7/wsgiref/handlers.py", line 212, in write
self.send_headers()
File "/usr/lib/python2.7/wsgiref/handlers.py", line 270, in send_headers self.send_preamble()
File "/usr/lib/python2.7/wsgiref/handlers.py", line 191, in send_preamble self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
File "/usr/lib/python2.7/wsgiref/handlers.py", line 391, in _write self.stdout.write(data)
File "/usr/lib/python2.7/socket.py", line 328, in write
self.flush()
File "/usr/lib/python2.7/socket.py", line 307, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 104] Connection reset by peer
Client side:
HTTPConnectionPool(host='mywebsite.com', port=3456): Max retries exceeded with url: /project/result.json (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
I have tuned the mysql configuration for higher max_connections and timeout but it doesn't work.
Can anyone help me to resolve the issue? Thanks.
Related
So, I am trying to install, and run Mujoco-py on my ubuntu. Everything went well but, I cant install the libglew1.5. I searche for it in the Ubuntu Package Archives, but no luck. Then I skipped that part, but when im trying to run the example its giving me this error.
(mujoco_py) user#user:~/.mujoco/mujoco-py/examples$ python3 setting_state.py
Creating window glfw
libEGL warning: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libEGL warning: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
GLFW error (code %d): %s 65542 b'EGL: Failed to initialize EGL: EGL is not or could not be initialized'
Traceback (most recent call last):
File "setting_state.py", line 32, in <module>
viewer = MjViewer(sim)
File "/home/sazzad14/.mujoco/mujoco-py/mujoco_py/mjviewer.py", line 137, in __init__
super().__init__(sim)
File "/home/sazzad14/.mujoco/mujoco-py/mujoco_py/mjviewer.py", line 28, in __init__
super().__init__(sim)
File "mjrendercontext.pyx", line 311, in mujoco_py.cymj.MjRenderContextWindow.__init__
File "mjrendercontext.pyx", line 46, in mujoco_py.cymj.MjRenderContext.__init__
File "mjrendercontext.pyx", line 102, in mujoco_py.cymj.MjRenderContext._setup_opengl_context
File "opengl_context.pyx", line 48, in mujoco_py.cymj.GlfwContext.__init__
File "opengl_context.pyx", line 99, in mujoco_py.cymj.GlfwContext._create_window
mujoco_py.cymj.GlfwError: Failed to create GLFW window
I installed libglew2.2, but that does not help.
I have installed gcloud sdk by following the link https://cloud.google.com/sdk/docs/downloads-apt-get on Ubuntu 16.04.6 LTS. I have also done the proxy configuration using the following link https://cloud.google.com/sdk/docs/proxy-settings.
Google Cloud SDK 288.0.0
alpha 2020.04.03
beta 2020.04.03
bq 2.0.56
core 2020.04.03
gsutil 4.49
kubectl 2020.04.03
gcloud init is successful and gcloud info --run-diagnostics displays no problems. However gcloud crashes for any other commands I run. I have tried the following commands.
1. gcloud compute images list
2. gcloud services list
3. gcloud logging logs list
Here is the message I get after the crash.
ERROR: gcloud crashed (SSLHandshakeError): [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)
If you would like to report this issue, please run the following command:
gcloud feedback
To check gcloud for common problems, please run the following command:
gcloud info --run-diagnostics
Can someone please help.
PS. Here is debug output.
DEBUG: Running [gcloud.compute.images.list] with arguments: [--verbosity: "debug"]
INFO: Refreshing access_token
INFO: Display format: " table(
name,
selfLink.map().scope(projects).segment(0):label=PROJECT,
family,
deprecated.state:label=DEPRECATED,
status
)"
DEBUG: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 983, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 809, in Run
display_info=self.ai.display_info).Display()
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/display.py", line 483, in Display
self._printer.Print(self._resources)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/resource/resource_printer_base.py", line 275, in Print
for resource in resources:
File "/usr/lib/google-cloud-sdk/lib/surface/compute/images/list.py", line 113, in _FilterDeprecated
for image in images:
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/compute/lister.py", line 1065, in __call__
errors=errors):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/compute/request_helper.py", line 204, in ListJson
for item in _ListCore(requests, http, batch_url, errors, _HandleJsonList):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/compute/request_helper.py", line 134, in _ListCore
requests=requests, http=http, batch_url=batch_url)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/compute/batch_helper.py", line 106, in MakeRequests
batch_request_callback=batch_checker.BatchCheck)
File "/usr/bin/../lib/google-cloud-sdk/lib/third_party/apitools/base/py/batch.py", line 226, in Execute
batch_http_request.Execute(http)
File "/usr/bin/../lib/google-cloud-sdk/lib/third_party/apitools/base/py/batch.py", line 492, in Execute
self._Execute(http)
File "/usr/bin/../lib/google-cloud-sdk/lib/third_party/apitools/base/py/batch.py", line 449, in _Execute
response = http_wrapper.MakeRequest(http, request)
File "/usr/bin/../lib/google-cloud-sdk/lib/third_party/apitools/base/py/http_wrapper.py", line 356, in MakeRequest
max_retry_wait, total_wait_sec))
File "/usr/bin/../lib/google-cloud-sdk/lib/third_party/apitools/base/py/http_wrapper.py", line 304, in HandleExceptionsAndRebuildHttpConnections
raise retry_args.exc
SSLHandshakeError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)
ERROR: gcloud crashed (SSLHandshakeError): [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)
I got it working after some debugging. Seems like firewall was the issue in my case. I shifted to python 3.5 . After which I ran the same command gcloud compute images list
I got the error "Caught socket error, retrying request to url https://compute.googleapis.com/batch/compute/v1". Adding this url to firewall exception solved my issue.
I'm trying to install Tryton ERP with MySQL as the database. It's not quite clear what you are meant to do.
From the config documentation you simply supply the uri to the database under the [database] section:
[database]
uri = mysql://user:pass#localhost:3306
However running trytond -v -c /home/user/.config/tryton/3.8/tryton.conf does not seem to get it working. When trying to access the 127.0.0.1:8050 where I've got Tryton running, I simply get 127.0.0.1 - - [23/Nov/2015 16:55:10] code 404, message File not found
One would assume, Tryton either installs the database on its own or you need to create yourself somehow but I didn't see any documentation surrounding that.
I've also trying adding a database through the Tryton GUI, it encounters the following error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tryton/gui/window/dbcreate.py", line 65, in server_change
common.refresh_langlist(self.combo_language, host, port)
File "/usr/local/lib/python2.7/dist-packages/tryton/common/common.py", line 253, in refresh_langlist
lang_list = rpc.db_exec(host, port, 'list_lang')
File "/usr/local/lib/python2.7/dist-packages/tryton/rpc.py", line 57, in db_exec
result = getattr(connection.common.db, method)(None, None, *args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/local/lib/python2.7/dist-packages/tryton/jsonrpc.py", line 271, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1306, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1482, in parse_response
return u.close()
File "/usr/local/lib/python2.7/dist-packages/tryton/jsonrpc.py", line 134, in close
return json.loads(self.data, object_hook=object_hook)
File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 505, in loads
return cls(encoding=encoding, **kw).decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 389, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 1 column 2 (char 1)
I've got the prerequisites installed that were listed here and MySQL-python package installed, should there be anything else?
You should create a database on MySQL with it's own tools. Once the database is created you must initialize it using the following command:
trytond -c <config_file> -d <database name> --all
See for complete reference:
http://doc.tryton.org/3.8/trytond/doc/topics/setup_database.html#topics-setup-database.
Once finished, the server will ask for an admin password. Once entered you can conect using the tryton client with the admin user and the entered password.
In order to access tryton from web client you must install and configure the sao web interface, that can be found on:
https://www.npmjs.com/package/tryton-sao
I sow post on
How to enable MySQL client auto re-connect with MySQLdb?
I had the same problem, I use pythonanywhere.com and when I write p.save() I had error like below.
It says something about updating mysql to fix it, but I don't know what code or shell commands I need to write.
Can you help me?
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py", line 545, in save
force_update=force_update, update_fields=update_fields)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py", line 570, in save_base
with transaction.commit_on_success_unless_managed(using=using, savepoint=False):
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/transaction.py", line 280, in __enter__
connection.set_autocommit(False)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 340, in set_autocommit
self._set_autocommit(autocommit)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 461, in _set_autocommit
self.connection.autocommit(autocommit)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 461, in _set_autocommit
self.connection.autocommit(autocommit)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 243, in autocommit
_mysql.connection.autocommit(self, on)
OperationalError: (2006, 'MySQL server has gone away')
Your connection to the database was closed because it was idle for too long. From the traceback, it looks like you were doing your queries interactively. If you know that you've been idle for more than about 5 min, you should do this:
from django.db import connection; connection.close()
I solved the problem inserting this code where the connection will need to be restored and refreshed:
try:
cursor = connections['default'].cursor()
db = cursor.db
assert issubclass(db.__class__, BaseDatabaseWrapper)
if db.connection is None or not db.is_usable():
db.close_if_unusable_or_obsolete()
with db.wrap_database_errors:
db.connect()
logger.info('Restoring the Mysql Connection')
except Exception as e:
logger.exception('DB Connection error')
Please notice that I use connections['default'] because I have multiple databases configured so you can set a specific connection, notice also that I use db.is_usable() so to call the .ping() to allow to restore a connection when is possible instead of always closing the connection.
Anytime I try to do any interaction with the server, Mercurial returns "abort: HTTP Error 400: Bad Request". We are not using any authentication, so that's not an issue. We have three other developers working on the same repo with the same version of mercurial installed (2.2.3). They haven't had any issues, so it makes me think I'm corrupting something in the .hg folder or something. But I really have no clue.
I was able to clone and work from the new directory just fine. However, about 4 hours later, it started happening again in the new directory too. The only things I did in that time period were commit, pull, and push. When I committed a few hours later and tried to pull, that's when I got the error again.
Here is the debug log for incoming (hg --debug --traceback incoming):
using http://myserver/myapp
sending capabilities command
comparing with http://myserver/myapp
query 1; heads
sending batch command
searching for changes
taking initial sample
searching: 2 queries
query 2; still undecided: 208, sample size is: 200
sending known command
Traceback (most recent call last):
File "mercurial\dispatch.pyo", line 88, in _runcatch
File "mercurial\dispatch.pyo", line 740, in _dispatch
File "mercurial\dispatch.pyo", line 514, in runcommand
File "mercurial\dispatch.pyo", line 830, in _runcommand
File "mercurial\dispatch.pyo", line 801, in checkargs
File "mercurial\dispatch.pyo", line 737, in <lambda>
File "mercurial\util.pyo", line 472, in check
File "mercurial\extensions.pyo", line 144, in wrap
File "mercurial\util.pyo", line 472, in check
File "hgext\mq.pyo", line 3528, in mqcommand
File "mercurial\util.pyo", line 472, in check
File "mercurial\commands.pyo", line 3894, in incoming
File "mercurial\hg.pyo", line 513, in incoming
File "mercurial\hg.pyo", line 472, in _incoming
File "mercurial\bundlerepo.pyo", line 342, in getremotechanges
File "mercurial\discovery.pyo", line 45, in findcommonincoming
File "mercurial\setdiscovery.pyo", line 184, in findcommonheads
File "mercurial\wireproto.pyo", line 116, in plain
File "mercurial\wireproto.pyo", line 164, in _submitone
File "mercurial\httppeer.pyo", line 170, in _call
File "mercurial\httppeer.pyo", line 118, in _callstream
File "urllib2.pyo", line 406, in open
File "urllib2.pyo", line 519, in http_response
File "urllib2.pyo", line 444, in error
File "urllib2.pyo", line 378, in _call_chain
File "urllib2.pyo", line 527, in http_error_default
HTTPError: HTTP Error 400: Bad Request
abort: HTTP Error 400: Bad Request
As I said earlier, I can do a clone, but if I try to run incoming, outgoing, pull, or push, I get this error.
I was able to resolve this issue by running
hg rollback
Once I ran that, it uncommitted my files (but kept the changes, so I could see the modified files in hg status). I was then able to run incoming and pull. Then I re-committed my code and pushed it out without any problems.
So something must be getting corrupted when I commit, just not sure why.
I don't know what's the problem in this specific case. But we had a different problem with the same result - incoming and pull commands failed with 400 Bad Request. So here's receipt for how to investigate the failure, in case hg -v --debug doesn't help.
Take Fiddler for capturing and revealing HTTP traffic. Then run mercurial request as following:
hg --config http_proxy.host=127.0.0.1:8888 pull
The config causes redirects of requests through Fiddler, which is listening on port 8888. Then in Fiddler, you may find the red 400 reply and in Inspectors pane to see an entire message, not the code only.
You may look here for details on our problem, investigation and resolution.