requests.exceptions.ConnectionError

1,056 views
Skip to first unread message

Tsrif Tsal

unread,
Dec 23, 2019, 5:21:32 PM12/23/19
to Kivy users support
Hi again,
I cannot establish connection with api endpoint with requests library, which is included in buildozer requirements.
I get this error:
12-23 07:26:12.097 30692 30844 I python  :  requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7186017a90>: Failed to establish a new connection: [Errno 111] Connection refused'))
Someone suggested to include lxml in buildozer requirements as well. Is it worth to try?

However, I can make connection with kivy UrlRequest but I don't want to use it because I have to define on_success function which will be outside of my working function. I want to execute instructions one by one. Or can I use UrlRequest to do this?


Tsrif Tsal

unread,
Dec 23, 2019, 5:26:42 PM12/23/19
to Kivy users support
In urlrequest.py there is a function wait.

def wait(self, delay=0.5):
'''Wait for the request to finish (until :attr:`resp_status` is not
None)

.. note::
This method is intended to be used in the main thread, and the
callback will be dispatched from the same thread
from which you're calling.

.. versionadded:: 1.1.0
'''
while self.resp_status is None:
self._dispatch_result(delay)
sleep(delay)

Robert Flatt

unread,
Dec 23, 2019, 10:57:20 PM12/23/19
to Kivy users support
HTTPConnectionPool(host='127.0.0.1', port=5000):

It looks like this is an attempt to connect to a server on the phone, probably not what you intended.  ;)

Internet accesses on Android must be off the UI (main) thread, this is generally good practice on any OS.
If each access gets its own thread and order is important then initiate each access from the callback of the previous access.
However it is more efficient to let each access have an ID, and assemble the result in what ever order the IDs arrive.
Reply all
Reply to author
Forward
0 new messages