OCA / odoorpc

Python module to pilot your Odoo servers through JSON-RPC.
http://pythonhosted.org/OdooRPC/
GNU Lesser General Public License v3.0
231 stars 123 forks source link

[Errno -2] Name or service not known #72

Closed bosd closed 1 year ago

bosd commented 2 years ago

When trying to connect to an instance the following error occurs: [Errno -2] Name or service not known

To Reproduce

Affected versions:

Steps to reproduce the behavior:

  1. open python shell Python3
  2. > import odoorpc
    > odoo = odoorpc.ODOO('IPADRESS', port=443)  
  3. Obsere the error:
  File "/usr/lib/python3.7/urllib/request.py", line 1324, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.7/http/client.py", line 1260, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1306, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1255, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1030, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 970, in send
    self.connect()
  File "/usr/lib/python3.7/http/client.py", line 942, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/odoo.py", line 96, in __init__
    self._host, self._port, timeout, version, opener=opener
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/__init__.py", line 211, in __init__
    self._proxy_json, self._proxy_http = self._get_proxies()
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/__init__.py", line 235, in _get_proxies
    result = proxy_json('/web/webclient/version_info')['result']
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/jsonrpclib.py", line 113, in __call__
    response = self._opener.open(request, timeout=self._timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1352, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.7/urllib/request.py", line 1326, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>
>>> odoo = odoorpc.ODOO('77.72.144.253:443', port=443)
Traceback (most recent call last):
  File "/usr/lib/python3.7/urllib/request.py", line 1324, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.7/http/client.py", line 1260, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1306, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1255, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1030, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 970, in send
    self.connect()
  File "/usr/lib/python3.7/http/client.py", line 942, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/odoo.py", line 96, in __init__
    self._host, self._port, timeout, version, opener=opener
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/__init__.py", line 211, in __init__
    self._proxy_json, self._proxy_http = self._get_proxies()
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/__init__.py", line 235, in _get_proxies
    result = proxy_json('/web/webclient/version_info')['result']
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/jsonrpclib.py", line 113, in __call__
    response = self._opener.open(request, timeout=self._timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1352, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.7/urllib/request.py", line 1326, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>
>>> odoo = odoorpc.ODOO('77.72.144.253:443', port=443)
Traceback (most recent call last):
  File "/usr/lib/python3.7/urllib/request.py", line 1324, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.7/http/client.py", line 1260, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1306, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1255, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1030, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 970, in send
    self.connect()
  File "/usr/lib/python3.7/http/client.py", line 942, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/odoo.py", line 96, in __init__
    self._host, self._port, timeout, version, opener=opener
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/__init__.py", line 211, in __init__
    self._proxy_json, self._proxy_http = self._get_proxies()
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/__init__.py", line 235, in _get_proxies
    result = proxy_json('/web/webclient/version_info')['result']
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/jsonrpclib.py", line 113, in __call__
    response = self._opener.open(request, timeout=self._timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1352, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.7/urllib/request.py", line 1326, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>
>>> odoo = odoorpc.ODOO('77.72.144.253', port=443)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/odoo.py", line 96, in __init__
    self._host, self._port, timeout, version, opener=opener
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/__init__.py", line 211, in __init__
    self._proxy_json, self._proxy_http = self._get_proxies()
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/__init__.py", line 235, in _get_proxies
    result = proxy_json('/web/webclient/version_info')['result']
  File "/home/bosd/.local/lib/python3.7/site-packages/odoorpc/rpc/jsonrpclib.py", line 113, in __call__
    response = self._opener.open(request, timeout=self._timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1352, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.7/urllib/request.py", line 1327, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.7/http/client.py", line 1352, in getresponse
    response.begin()
  File "/usr/lib/python3.7/http/client.py", line 310, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.7/http/client.py", line 292, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: 

Expected behavior An error handler with detailed feedback what went wrong.

Additional context Os mx Linux 12 Python 3.7

ruiztulio commented 2 years ago

@bosd try:

odoo = odoorpc.ODOO('IPADRESS', port=443, protocol='jsonrpc+ssl')

Regards

sebalix commented 1 year ago

The answer from @ruiztulio seems the good one, it's not an issue related to OdooRPC here. Closing.

lucasub commented 1 year ago

Work also with hostname: odoo = odoorpc.ODOO('www.xxx.yy', port=443, protocol='jsonrpc+ssl')