grammar-check icon indicating copy to clipboard operation
grammar-check copied to clipboard

Connection Reset by Peer

Open zachsamuels opened this issue 6 years ago • 3 comments

When trying to run the check function I am running into the error: grammar_check.ServerError: http://127.0.0.1:8081: [Errno 104] Connection reset by peer Here is the full Traceback:

Traceback (most recent call last):
  File "/home/MYUSERNAME/grammar-check/grammar_check/__init__.py", line 302, in _get_root
    with urlopen(url, data, cls._TIMEOUT) as f:
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.6/urllib/request.py", line 1321, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/MYUSERNAME/grammar-check/grammar_check/__init__.py", line 370, in _start_server
    with urlopen(cls._url, data, cls._TIMEOUT) as f:
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.6/urllib/request.py", line 1321, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/MYUSERNAME/grammar-check/grammar_check/__init__.py", line 243, in check
    root = self._get_root(self._url, self._encode(text, srctext))
  File "/home/MYUSERNAME/grammar-check/grammar_check/__init__.py", line 306, in _get_root
    cls._start_server()
  File "/home/MYUSERNAME/grammar-check/grammar_check/__init__.py", line 375, in _start_server
    raise ServerError('{}: {}'.format(cls._url, e))
grammar_check.ServerError: http://127.0.0.1:8081: [Errno 104] Connection reset by peer

Is there any reason for this and/or a way to fix it?

zachsamuels avatar Nov 21 '18 23:11 zachsamuels

I have this issue too, can you help us resolve this @viraja1

kunchamharsha avatar Apr 11 '19 04:04 kunchamharsha

you need to modify grammar_check/__init__.py

function get_server_cmd(port=None) doesn't work with new versions of java here is what i changed it to to make it work:

def get_server_cmd(port=None):
    try:
        cmd = cache['server_cmd']
    except KeyError:
        java_path, jar_path = get_jar_info()
        cmd = [java_path,  '--add-modules', 'java.xml.bind', '-cp', jar_path, 'org.languagetool.server.HTTPServer']
        cache['server_cmd'] = cmd
    return cmd if port is None else cmd + ['-p', str(port)]

all that is different is i added '--add-modules', 'java.xml.bind', after java_path, in cmd variable

i'm sure the proper way of doing this would be to check the java version, and only add this if needed, because it might break if you try using it this way with an old version of java

https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j

haasosaurus avatar Sep 23 '19 00:09 haasosaurus

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!

jxmorris12 avatar May 01 '20 16:05 jxmorris12