myint / language-check

Python wrapper for LanguageTool grammar checker
https://pypi.python.org/pypi/language-check
GNU Lesser General Public License v3.0
327 stars 101 forks source link

grammar_check.ServerError: http://127.0.0.1:8081: [Errno 104] Connection reset by peer #61

Open rodriguesfas opened 6 years ago

rodriguesfas commented 6 years ago

I am processing a set of documents, at first okay, but then, at a certain moment happens that error, it is as if the request was blocked ..

Traceback (most recent call last): File "/home/rodriguesfas/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/ptvsd_launcher.py", line 118, in vspd.debug(filename, port_num, '', '', run_as) File "/home/rodriguesfas/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/ptvsd/ptvsd/debugger.py", line 37, in debug run(address, filename, *args, kwargs) File "/home/rodriguesfas/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/ptvsd/ptvsd/_local.py", line 79, in run_file run(argv, addr, kwargs) File "/home/rodriguesfas/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/ptvsd/ptvsd/_local.py", line 140, in _run _pydevd.main() File "/home/rodriguesfas/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 1760, in main globals = debugger.run(setup['file'], None, None, is_module) File "/home/rodriguesfas/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 1107, in run return self._exec(is_module, entry_point_fn, module_name, file, globals, locals) File "/home/rodriguesfas/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 1114, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/home/rodriguesfas/Mestrado/workspace/specana.prototype/script/test_language_check.py", line 58, in check_sentence(sentence) File "/home/rodriguesfas/Mestrado/workspace/specana.prototype/script/test_language_check.py", line 36, in check_sentence matches = tool.check(sentence) File "/home/rodriguesfas/.local/lib/python2.7/site-packages/grammar_check/init.py", line 246, in check root = self._get_root(self._url, self._encode(text, srctext)) File "/home/rodriguesfas/.local/lib/python2.7/site-packages/grammar_check/init.py", line 309, in _get_root cls._start_server() File "/home/rodriguesfas/.local/lib/python2.7/site-packages/grammar_check/init.py", line 378, in _start_server raise ServerError(u'{}: {}'.format(cls._url, e)) grammar_check.ServerError: http://127.0.0.1:8081: [Errno 104] Connection reset by peer

Amrouane commented 5 years ago

I had the same problem, allowing the port 8081 in the firewall did the trick for me.

louhow commented 5 years ago

I think you may have been having a separate issue @Amrouane, @rodriguesfas is saying that the program works for awhile, until it doesn't. If it were a firewall issue, then the server would never work in the first place.

@rodriguesfas - I'm seeing the same thing when I get to around ~900-1000 documents searched. It seems deterministic, but I'm not sure why it happens. I reduced the timeout from 60 seconds to something quicker (like 2 seconds), and then just re-create the tool (e.g. tool = grammar_check.LanguageTool('en-US')) and it keeps chugging along.

It looks like this library has some logic to kill and re-start the server on timeout, but it seems to be buggy.

jxmorris12 commented 4 years ago

Hi! Since this project has been abandoned, I started a new fork over at https://github.com/jxmorris12/language_tool_python.

My version supports new versions of Java and LanguageTool. language-check is stuck on Java 8 and LanguageTool 3.2; latest versions are Java 14 and LanguageTool 4.9!

I'm happy to help you with your issue if you raise it over at my repository! Thanks!