xiaocong / uiautomator

Python wrapper of Android uiautomator test tool.
MIT License
2.03k stars 638 forks source link

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=' localhost', port=9009): Max retries exceeded with url: /jsonrpc/0 (Caused by <class 'httplib.BadStatusLine'> #70

Open henrydeng opened 10 years ago

henrydeng commented 10 years ago

when loop settext() function in the editbox of sms for many times, it will thrown this exception: urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=' localhost', port=9009): Max retries exceeded with url: /jsonrpc/0 (Caused by <class 'httplib.BadStatusLine'>

LOG: 2014-09-01 12:28:54,585 : File "C:\StressTest\StressTest\common\message.py", line 38, in sms_Send 2014-09-01 12:28:54,586 : d1(className='android.widget.EditText').set_text(dA_jMViJ8!2t6LFx3D[QK{AO5EG-'O)~hqW]0yYQuk@qU870f~iZobql95?EWDc<2aQqCQsBjHSU|&X$v|DtcU7aX<PHzg}Rl<N!{5rtK_Wmq_Dg'2jALmM_Nta{^pRYJa^+K+XrVlb0'[?@G0^ZJr}9S<Z&([SlkV_bL&[^ed29P+cU5i_y14Uf}|_3Qgoh|3c8+%) 2014-09-01 12:28:54,586 : File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomatorinit.py", line 1311, in set_text 2014-09-01 12:28:54,586 : return self.jsonrpc.setText(self.selector, text) 2014-09-01 12:28:54,587 : File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomatorinit.py", line 453, in wrapper 2014-09-01 12:28:54,587 : return _JsonRPCMethod(url, method, timeout, False)(_args, _kwargs) 2014-09-01 12:28:54,588 : File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomatorinit.py", line 448, in wrapper 2014-09-01 12:28:54,588 : return _method_obj(_args, _kwargs) 2014-09-01 12:28:54,588 : File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomatorinit.py", line 134, in call 2014-09-01 12:28:54,588 : timeout=self.timeout) 2014-09-01 12:28:54,589 : File "build\bdist.win32\egg\urllib3\poolmanager.py", line 155, in urlopen 2014-09-01 12:28:54,589 : File "build\bdist.win32\egg\urllib3\connectionpool.py", line 562, in urlopen 2014-09-01 12:28:54,589 : File "build\bdist.win32\egg\urllib3\connectionpool.py", line 562, in urlopen 2014-09-01 12:28:54,590 : File "build\bdist.win32\egg\urllib3\connectionpool.py", line 562, in urlopen 2014-09-01 12:28:54,590 : File "build\bdist.win32\egg\urllib3\connectionpool.py", line 543, in urlopen 2014-09-01 12:28:54,590 : urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=' localhost', port=9009): Max retries exceeded with url: /jsonrpc/0 (Caused by <class 'httplib.BadStatusLine'>: '')

when query by this comand[ curl -d '{"jsonrpc":"2.0","method":"ping","id":"1234"}' -H 'Content-type: application/json' http://localhost:9009/jsonrpc/0 ] it response with parse error curl: (6) Could not resolve host: application {"jsonrpc":"jsonrpc","id":"null","error":{"code":-32700,"message":"Parse error"} }

henrydeng commented 10 years ago

another logcat ,please download at http://pan.baidu.com/s/1qWM6JZQ

140901 16:34:39.483: [INFO] [MAIN] [sms] Trace test_content IC3Ut>+3OC]3Tb[xM1A>1z{_uwctR+A$BVtYdjt1@( 140901 16:34:39.483: [INFO] [MAIN] [sms] Trace test_times 41 Traceback (most recent call last): File "C: \StressTest\StressTest\settext2.py", line 48, in main() File "C:\ StressTest\StressTest\settext2.py", line 44, in main sms() File "C:\ StressTest\StressTest\settext2.py", line 35, in sms mdevice(className='android.widget.EditText').set_text(content) File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomatorinit.py", line 1311, in set_text return self.jsonrpc.setText(self.selector, text) File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomatorinit.py", line 453, in wrapper return _JsonRPCMethod(url, method, timeout, False)(_args, _kwargs) File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomatorinit.py", line 448, in wrapper return _method_obj(_args, _kwargs) File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomatorinit.py", line 134, in call timeout=self.timeout) File "build\bdist.win32\egg\urllib3\poolmanager.py", line 155, in urlopen File "build\bdist.win32\egg\urllib3\connectionpool.py", line 562, in urlopen File "build\bdist.win32\egg\urllib3\connectionpool.py", line 562, in urlopen File "build\bdist.win32\egg\urllib3\connectionpool.py", line 562, in urlopen File "build\bdist.win32\egg\urllib3\connectionpool.py", line 543, in urlopen urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=9009): Max retries exceeded with url: /jsonrpc/0 (Caused by <class 'httplib.BadStatusLine'>: '')

xiaocong commented 10 years ago

Likely something wrong with jsonrpc server, but I didn't find clue form logcat...

henrydeng commented 10 years ago

I can reproduce it both on MTK and Qualcom Platform when loop to call settext for many times ,could you try to reproduce it?

and I found one stop command from one of the logs.is the server stop working?

2014-08-25 13:15:30,546 : 08-25 13:15:31.000 D/UIAutomatorStub(21590): URI: /stop, Method: GET, Header: {user-agent=Python-urllib/2.7, connection=close, remote-addr=127.0.0.1, host=localhost:9009, accept-encoding=identity, http-client-ip=127.0.0.1}, params, {NanoHttpd.QUERY_STRING=null}, files: {}

xiaocong commented 10 years ago

@henrydeng the stop command is to try to restart the server.

Per log below

{"jsonrpc":"jsonrpc","id":"null","error":{"code":-32700,"message":"Parse error"}

Likely the server could not parse the content you sent to it, so I assume there was something wrong with the jsonrpc server. To root cause it, I have to reproduce it on my PC.

henrydeng commented 10 years ago

got it, it seems this issue only happen when the string in settext() contain special charaters ,such as (!@##$%^&**(()).