Digital Developer Conference: a FREE half-day online conference focused on AI & Cloud – North America: Nov 2 – India: Nov 9 – Europe: Nov 14 – Asia Nov 23 Register now

Close outline
  • United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

Waton Developer Cloud Python SDK sometimes returnes NewConnectionError

1200005YSG gravatar image
Question by Daisuke  (1) | Jan 10, 2017 at 02:21 AM watsonpythonnatural-language-classifierpython-sdk

My customer uses Watson Developer Cloud Python SDK and calls NLC services for evaluation classifiers' performance. When they called NLC many times in loop, sometimes NLC returned NewConnectionError and stopped python script.

Error message is as follows.


Traceback (most recent call last): File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 138, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\util\connection.py", line 98, in create_connection raise err File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\util\connection.py", line 88, in create_connection sock.connect(sa) TimeoutError: [WinError 10060] 接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗しました。

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 594, in urlopen chunked=chunked) File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 350, in _make_request self._validate_conn(conn) File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 835, in _validate_conn conn.connect() File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 281, in connect conn = self._new_conn() File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 147, in _new_conn self, "Failed to establish a new connection: %s" % e) requests.packages.urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [WinError 10060] 接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗しました。

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Anaconda3\lib\site-packages\requests\adapters.py", line 423, in send timeout=timeout File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 643, in urlopen _stacktrace=sys.exc_info()[2]) File "C:\Anaconda3\lib\site-packages\requests\packages\urllib3\util\retry.py", line 363, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='gateway.watsonplatform.net', port=443): Max retries exceeded with url: /natural-language-classifier/api/v1/classifiers/ff1b44x158-nlc-617/classify (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 100 60] 接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗しました。',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "NLC.py", line 24, in classes = natural_language_classifier.classify(classifier_id[i], text) File "C:\Anaconda3\lib\site-packages\watson_developer_cloud\natural_language_classifier_v1.py", line 63, in classify json={'text': text}) File "C:\Anaconda3\lib\site-packages\watson_developer_cloud\watson_developer_cloud_service.py", line 298, in request **kwargs) File "C:\Anaconda3\lib\site-packages\requests\api.py", line 56, in request return session.request(method=method, url=url, **kwargs) File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 488, in request resp = self.send(prep, **send_kwargs) File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 609, in send r = adapter.send(request, **kwargs) File "C:\Anaconda3\lib\site-packages\requests\adapters.py", line 487, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='gateway.watsonplatform.net', port=443): Max retries exceeded with url: /natural-language-classifier/api/v1/classifiers/ff1b44x158-nlc-617/classify (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] 接続済みの 呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗しました。',))


I found similar issue posted here, but the issue doesn't seems to be resolved. https://developer.ibm.com/answers/questions/292691/is-data-transfer-to-watson-vision-reco-with-python/?smartspace=watson

Sometimes they can succeed to complete script without errors, so I think this is not caused by user program logic. Could anyone give me solutions about it?

Thanks.

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

1 reply

  • Sort: 
110000PNBC gravatar image

Answer by @chughts (12979) | Jan 10, 2017 at 03:37 AM

I am guessing that as you are getting errors in and whilst repeating invoking methods on urllib3 then you are hitting a resource limitation in Python on your machine. This could either be a thread limit or an open connection limit, which will be further affected if you are making async calls. Either way you need to batch up the calls so that thread or connection resources are cleanly freed up allowing them to be reused.

It looks like you are trying a fresh call on the exception handling which is failing as the resources you need haven't been freed up yet.

Comment

People who like this

  0   Show 1   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
1200005YSG gravatar image Daisuke (1)   Jan 16, 2017 at 09:11 PM 0
Share

Thank you for your comment and I'm sorry to respond too late.

I doubted that this was caused by limitation of sockets so I already checked socket status by using both netstat command and netsh command while program was running. (Client program runs on Windows PC(Win 7).) As a result, program used different sockets for each call but calls were serialized and use sockets one by one. So I think this is not caused by any limits(thread limit, open connection limit and so on).

As you say it is one solution to add exception handling and I will add to my source code. But I also want to know route causes of this issue and underlying solutions. If anyone have ideas, I'm happy to hear them.

Thank you!

Follow this question

108 people are following this question.

Answers

Answers & comments

Related questions

Hi there, I am trying to read from a sample pdf file and print json object using document conversion api, but I keep getting the error 400 3 Answers

Uploading Document Conversion output to Retrieve and Rank service using python 1 Answer

speech to text client python seems incomplete 2 Answers

Supported Python v2.6 library for IBM Watson Visual Recognition 1 Answer

Set X-Watson-Learning-Opt-Out with Natural Language Classifier - Python 1 Answer

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • Data and AI
  • DataPower
  • Decision Optimization
  • DevOps Build
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • Hyper Protect
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PartnerWorld Developer Support
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges