Getting [Errno 110] 'Connection timed out' when trying to do get requests in python - TagMerge
4Getting [Errno 110] 'Connection timed out' when trying to do get requests in pythonGetting [Errno 110] 'Connection timed out' when trying to do get requests in python

Getting [Errno 110] 'Connection timed out' when trying to do get requests in python

Asked 1 years ago
2
4 answers

Now Get request is working , by setting the proxies with port number.

Added proxy setting in above code:

proxies = { 'http': 'web-proxy.xxxxxx.xx.com:8080','https': 'web-proxy.xxxxxx.xx.com:8080'}

Output :
200
{
  "version" : "1.0",
  "email_address" : "xxxx@emailin.com"
}

Source: link

-1

check your internet connection, you may not be connected to the internet properly, and connecting through a air gap is really hard

Source: link

0

paolorotolo@linux-jwyh:~/dev/tensorflow-codelab/tensorflow-mnist-tutorial> python3 mnist_1.0_softmax.py 
Traceback (most recent call last):
  File "/usr/lib64/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib64/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/lib64/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib64/python3.6/socket.py", line 722, in create_connection
    raise err
  File "/usr/lib64/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mnist_1.0_softmax.py", line 39, in <module>
    mnist = read_data_sets("data", one_hot=True, reshape=False, validation_size=0)
  File "/home/paolorotolo/.local/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py", line 211, in read_data_sets
    SOURCE_URL + TRAIN_IMAGES)
  File "/home/paolorotolo/.local/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 208, in maybe_download
    temp_file_name, _ = urlretrieve_with_retry(source_url)
  File "/home/paolorotolo/.local/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 165, in wrapped_fn
    return fn(*args, **kwargs)
  File "/home/paolorotolo/.local/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 190, in urlretrieve_with_retry
    return urllib.request.urlretrieve(url, filename)
  File "/usr/lib64/python3.6/urllib/request.py", line 248, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/usr/lib64/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib64/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib64/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.6/urllib/request.py", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib64/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>

Source: link

0

Code: Select all
import quickoled, ntptime, utime, random, network, wificonnect
while True:
    quickoled.oled.fill(0)
    time = ntptime.time()
    tm = utime.localtime(time)
    randomY = random.randint(0,108)
    randomX = random.randint(0,64)
    print((tm[0], tm[1], tm[2], tm[6] + 7, tm[3], tm[4], tm[5], 0))
    dateStr = str(tm[2]) + " - " + str(tm[1]) + " - " + str(tm[0])
    timeStr = str(tm[6] + 7) + ":" + str(tm[3]) + ":" + str(tm[4]) + ":" + str(tm[5])
    quickoled.oled.text(dateStr, randomX, randomY, 1)
    quickoled.oled.text(dateStr, randomX, randomY + 10, 1)
    quickoled.oled.show()
Code: Select all
try:
    import usocket as socket
except:
    import socket
try:
    import ustruct as struct
except:
    import struct
# (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60
NTP_DELTA = 3155673600

host = "pool.ntp.org"

def time():
    NTP_QUERY = bytearray(48)
    NTP_QUERY[0] = 0x1b
    addr = socket.getaddrinfo(host, 123)[0][-1]
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        s.settimeout(5)
        res = s.sendto(NTP_QUERY, addr)
        msg = s.recv(48)
    finally:
        s.close()
    val = struct.unpack("!I", msg[40:44])[0]
    return val - NTP_DELTA

# There's currently no timezone support in MicroPython, so
# utime.localtime() will return UTC time (as if it was .gmtime())
def settime():
    t = time()
    import machine
    import utime
    tm = utime.localtime(t)
    machine.RTC().datetime((tm[0], tm[1], tm[2], tm[6] + 1, tm[3], tm[4], tm[5], 0))

Source: link

Recent Questions on python

    Programming Languages