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

Failed to establish a new connection: [Errno 61] Connection refused #98

Closed
fysteven opened this issue Apr 19, 2016 · 7 comments
Closed

Comments

@fysteven
Copy link

fysteven commented Apr 19, 2016

Tried using Tika-Python earlier today. Got the following error. Seems to be exceeding some maximum connections.

It also seems to be a problem with Tika Server.

Traceback (most recent call last):
File "yao_file_detector.py", line 40, in
main()
File "yao_file_detector.py", line 36, in main
detect_files('/Users/Frank/working-directory/fulldump/file-type.txt')
File "yao_file_detector.py", line 23, in detect_files
file_type = detector.from_file(''.join([base_directory, val]))
File "/Library/Python/2.7/site-packages/tika/detector.py", line 22, in from_file
jsonOutput = detectType1('type', filename)
File "/Library/Python/2.7/site-packages/tika/tika.py", line 223, in detectType1
verbose, tikaServerJar)
File "/Library/Python/2.7/site-packages/tika/tika.py", line 256, in callServer
resp = verbFn(serviceUrl, encodedData, headers=headers)
File "/Library/Python/2.7/site-packages/requests/api.py", line 120, in put
return request('put', url, data=data, *_kwargs)
File "/Library/Python/2.7/site-packages/requests/api.py", line 53, in request
return session.request(method=method, url=url, *_kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, *_send_kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, *_kwargs)
File "/Library/Python/2.7/site-packages/requests/adapters.py", line 437, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=9998): Max retries exceeded with url: /detect/stream (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x118ec4590>: Failed to establish a new connection: [Errno 61] Connection refused',))

@chrismattmann
Copy link
Owner

Hi Frank @fysteven were you doing lots of parallel connections?

@fysteven
Copy link
Author

Hi Chris @chrismattmann , the following snippet is how I iterated the file list.
It failed around the 8181st detection of file.
Looks like the Tika Server would establish a new connection for each detection, right?

        for idx, val in enumerate(file_list):
            file_name = os.path.basename(val)
            file_type = detector.from_file(''.join([base_directory, val]))

@chrismattmann
Copy link
Owner

hi @fysteven any update here? Are you still seeing this?

@chrismattmann
Copy link
Owner

closing since I never heard back. Please re-open if you still see this.

@bainadeashish
Copy link

I am getting text contents from Azure web server with below code
from tika import parser
text = parser.from_file(file)--file is doc file

I am getting below error
HTTPConnectionPool(host='localhost', port=9998): Max retries exceeded with url: /rmeta/text (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions',))

@mahtani89
Copy link

Has anyone found a fix to the issue?

@chrismattmann
Copy link
Owner

The issue usually relates to:

  1. Your firewall doesn't allow incoming connections on localhost to 9998
  2. You already had your own Tika server running on 9998 (not started by Python) and something gets messed up - you need to kill that Tika server, and then let Python start it for you.

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

No branches or pull requests

4 participants