Bug 12940 - Python exception during DDNS update
Summary: Python exception during DDNS update
Status: NEW
Alias: None
Product: DDNS Updater
Classification: Unclassified
Component: Providers (show other bugs)
Version: unspecified
Hardware: unspecified Unspecified
: - Unknown - Minor Usability
Assignee: Stefan Schantl
QA Contact: Michael Tremer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-26 16:32 UTC by grisu127
Modified: 2024-01-26 11:49 UTC (History)
1 user (show)

See Also:


Attachments
another exeption (6.42 KB, text/plain)
2024-01-26 11:49 UTC, Porkyle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description grisu127 2022-09-26 16:32:29 UTC
This error message appears in the IPFire system log after each DDNS update.
For a some days I find this message one time each day. Then there are periods of 7 to 14 days where its not in the log.

Dynamic DNS update for [mydomain_redacted].com (freedns.afraid.org) threw an unhandled exception: 
Traceback (most recent call last): 
File "/usr/lib/python3 .10/site-packages/ddns/system.py", line 276, in get_address return self.__ad dresses[proto] KeyError: 'ipv4' During handling of the above exception, another exception occurred: 
Traceback (most recent call last): 
File "/usr/lib/python 3.10/urllib/request.py", line 1348, in do_open h.request(req.get_method(), r eq.selector, req.data, headers, 
File "/usr/lib/python3.10/http/client.py", lin e 1282, in request self._send_request(method, url, body, headers, encode_chu nked) 
File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request self.endheaders(body, encode_chunked=encode_chunked) 
File "/usr/lib/python3 .10/http/client.py", line 1277, in endheaders self._send_output(message_body , encode_chunked=encode_chunked) 
File "/usr/lib/python3.10/http/client.py", li ne 1037, in _send_output self.send(msg)
Comment 1 Porkyle 2024-01-10 22:07:17 UTC
After updating to core 182 I'm getting same error every every hour or so in my log. Manualy forcing update works fine without errors and if public ip changes update works and no errors but after some time from succesful update log starts to fill with errors. Internet connection works fine at time of error.

I'm using DMZ mode in my Huawei 4G router and it was working mostly without errors before core 182 update. I was getting randomly similar errors to DDNS log but my internet connection was broken also at sametime and rebooting router fixed that issue so I was thinking it was just issue with my connection.

When I switch 4G Router to bridged mode and DDNS update mode to classic (ip from RED interface) errors are gone.

Error from log
Dynamic DNS update for [redacted].dy.fi (dy.fi) threw an unhandled exception: Traceback (most recent call last):   File "/usr/lib/python3.10/site-packages/ddns/system.py", line 276, in get_address     return self.__addresses[proto] KeyError: 'ipv4'  During handling of the above exception, another exception occurred:  Traceback (most recent call last):   File "/usr/lib/python3.10/urllib/request.py", line 1348, in do_open     h.request(req.get_method(), req.selector, req.data, headers,   File "/usr/lib/python3.10/http/client.py", line 1282, in request     self._send_request(method, url, body, headers, encode_chunked)   File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request     self.endheaders(body, encode_chunked=encode_chunked)   File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders     self._send_output(message_body, encode_chunked=encode_chunked)   File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output     self.send(msg)   File "/usr/lib/pyth
Comment 2 Michael Tremer 2024-01-11 13:54:32 UTC
Could you please try to capture the entire exception? It seems to be cut off...
Comment 3 Porkyle 2024-01-11 14:19:01 UTC
That is where it cut's in log. But if there is another way to get that message I Will try.

Another note that that when using router in bridged mode and DDNS in "Guess the real public IP with help of an external server" mode I can't redproduce those errors. Now Errors seem to appear when RED is getting private area IP.

In dy.fi specifications there is mention if too many unnecessary request are made one might get blocked for a while, not sure if it's that since it seemed to work fine before. For refrence https://www.dy.fi/page/specification?lang=en
Comment 4 Porkyle 2024-01-12 22:21:38 UTC
I think I managed accidentally to get complete error message after executing [dhcpcd -k red0] and [dhcpcd -n red0] commands .

Dynamic DNS update for [redacted].dy.fi (dy.fi) threw an unhandled exception:
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 276, in get_address
    return self.__addresses[proto]
KeyError: 'ipv4'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3.10/http/client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/usr/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
TimeoutError: _ssl.c:980: The handshake operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/ddns/__init__.py", line 178, in _update
    entry(force=force)
  File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 157, in __call__
    elif self.has_failure or not self.requires_update:
  File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 202, in requires_update
    if self.ip_address_changed(self.protocols):
  File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 270, in ip_address_changed
    current_address = self.get_address(proto)
  File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 329, in get_address
    return self.core.system.get_address(proto) or default
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 281, in get_address
    self._get_address(proto)
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 309, in _get_address
    local_ip_address = self.guess_external_ip_address(proto)
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 122, in guess_external_ip_address
    return self._guess_external_ip_address(url, **kwargs)
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 99, in _guess_external_ip_address
    response = self.send_request(url, timeout=timeout)
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 167, in send_request
    resp = urllib.request.urlopen(req, timeout=timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/usr/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/usr/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error _ssl.c:980: The handshake operation timed out>
Comment 5 Michael Tremer 2024-01-14 15:24:55 UTC
(In reply to Porkyle from comment #3)
> That is where it cut's in log. But if there is another way to get that
> message I Will try.

You can just run "ddns update-all" on the console.

> Another note that that when using router in bridged mode and DDNS in "Guess
> the real public IP with help of an external server" mode I can't redproduce
> those errors. Now Errors seem to appear when RED is getting private area IP.

That should not be a problem, as it is a common setup. If ddns is detecting a private IP address it will resolve it externally.

> In dy.fi specifications there is mention if too many unnecessary request are
> made one might get blocked for a while, not sure if it's that since it
> seemed to work fine before. For refrence
> https://www.dy.fi/page/specification?lang=en

Generally we have protection against that in ddns. Once an update has failed, it might (depending on the return code it is getting back) hold off any further updates for some time.

(In reply to Porkyle from comment #4)
> I think I managed accidentally to get complete error message after executing
> [dhcpcd -k red0] and [dhcpcd -n red0] commands .
> 
> Dynamic DNS update for [redacted].dy.fi (dy.fi) threw an unhandled exception:
> Traceback (most recent call last):
>   File "/usr/lib/python3.10/site-packages/ddns/system.py", line 276, in
> get_address
>     return self.__addresses[proto]
> KeyError: 'ipv4'
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "/usr/lib/python3.10/urllib/request.py", line 1348, in do_open
>     h.request(req.get_method(), req.selector, req.data, headers,
>   File "/usr/lib/python3.10/http/client.py", line 1282, in request
>     self._send_request(method, url, body, headers, encode_chunked)
>   File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
>     self.endheaders(body, encode_chunked=encode_chunked)
>   File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
>     self._send_output(message_body, encode_chunked=encode_chunked)
>   File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
>     self.send(msg)
>   File "/usr/lib/python3.10/http/client.py", line 975, in send
>     self.connect()
>   File "/usr/lib/python3.10/http/client.py", line 1454, in connect
>     self.sock = self._context.wrap_socket(self.sock,
>   File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
>     return self.sslsocket_class._create(
>   File "/usr/lib/python3.10/ssl.py", line 1071, in _create
>     self.do_handshake()
>   File "/usr/lib/python3.10/ssl.py", line 1342, in do_handshake
>     self._sslobj.do_handshake()
> TimeoutError: _ssl.c:980: The handshake operation timed out
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "/usr/lib/python3.10/site-packages/ddns/__init__.py", line 178, in
> _update
>     entry(force=force)
>   File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 157, in
> __call__
>     elif self.has_failure or not self.requires_update:
>   File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 202, in
> requires_update
>     if self.ip_address_changed(self.protocols):
>   File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 270, in
> ip_address_changed
>     current_address = self.get_address(proto)
>   File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 329, in
> get_address
>     return self.core.system.get_address(proto) or default
>   File "/usr/lib/python3.10/site-packages/ddns/system.py", line 281, in
> get_address
>     self._get_address(proto)
>   File "/usr/lib/python3.10/site-packages/ddns/system.py", line 309, in
> _get_address
>     local_ip_address = self.guess_external_ip_address(proto)
>   File "/usr/lib/python3.10/site-packages/ddns/system.py", line 122, in
> guess_external_ip_address
>     return self._guess_external_ip_address(url, **kwargs)
>   File "/usr/lib/python3.10/site-packages/ddns/system.py", line 99, in
> _guess_external_ip_address
>     response = self.send_request(url, timeout=timeout)
>   File "/usr/lib/python3.10/site-packages/ddns/system.py", line 167, in
> send_request
>     resp = urllib.request.urlopen(req, timeout=timeout)
>   File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
>     return opener.open(url, data, timeout)
>   File "/usr/lib/python3.10/urllib/request.py", line 519, in open
>     response = self._open(req, data)
>   File "/usr/lib/python3.10/urllib/request.py", line 536, in _open
>     result = self._call_chain(self.handle_open, protocol, protocol +
>   File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
>     result = func(*args)
>   File "/usr/lib/python3.10/urllib/request.py", line 1391, in https_open
>     return self.do_open(http.client.HTTPSConnection, req,
>   File "/usr/lib/python3.10/urllib/request.py", line 1351, in do_open
>     raise URLError(err)
> urllib.error.URLError: <urlopen error _ssl.c:980: The handshake operation
> timed out>

This looks to me like you are having network errors. Can you reproduce this after the connection has been up for some time by manually running ddns?
Comment 6 Porkyle 2024-01-14 22:09:28 UTC
(In reply to Michael Tremer from comment #5)

> This looks to me like you are having network errors. Can you reproduce this
> after the connection has been up for some time by manually running ddns?

Yes, I did run it multiple times in row but only once it gave that error message. Other thing I noted that /var/ipfire/ddns/ddns.conf defaults to [guess_external_ip = False] even if in webgui it's set to True. Every time DDNS config is changed or rule disabled/enabled it changes guess_external_ip to False

Sometimes when guess external ip is enabled Webgui opens DynamicDNS page and Who is online addon page very slowly, it seems to hang when it resolves if DDNS is ok. My DNS servers are OK when pressing [check dns servers] button.

My router was in bridged mode and guess_externall_ip = true when run these.

[Fist time I force run DDNS from console]
Running on distribution: ipfire-2
Loading configuration file /var/ipfire/ddns/ddns.conf
Updating [redacted].dy.fi forced
Sending request (GET): https://checkip4.dns.lightningwirelabs.com
Request header:
  User-agent: IPFireDDNSUpdater/014
  Pragma: no-cache
Connection timeout
Dynamic DNS update for [redacted].dy.fi (dy.fi) successful
Logging successful update for [redacted].dy.fi
Opening database /var/lib/ddns.db

[Second time I got more info]
Running on distribution: ipfire-2
Loading configuration file /var/ipfire/ddns/ddns.conf
Updating [redacted].dy.fi forced
Sending request (GET): https://checkip4.dns.lightningwirelabs.com
Request header:
  User-agent: IPFireDDNSUpdater/014
  Pragma: no-cache
Response header (Status Code 200):
  content-length: 35
  vary: Accept-Encoding
  etag: "[redacted]"
  date: Sun, 14 Jan 2024 20:01:51 GMT
  content-type: text/html; charset=UTF-8
  strict-transport-security: max-age=31536000; includeSubDomains; preload
  connection: close
Sending request (GET): https://www.dy.fi/nic/update?hostname=[redacted].dy.fi&myip=[redacted]
Request header:
  Authorization: Basic [redacted]
  User-agent: IPFireDDNSUpdater/014
  Pragma: no-cache
Response header (Status Code 200):
  Server: nginx/1.10.3 (Ubuntu)
  Date: Sun, 14 Jan 2024 20:01:52 GMT
  Content-Type: text/plain;charset=UTF-8
  Transfer-Encoding: chunked
  Connection: close
  Last-Modified: Sun, 14 Jan 2024 20:01:52 GMT
  Cache-Control: no-cache
  Pragma: no-cache
Dynamic DNS update for [redacted].dy.fi (dy.fi) successful
Logging successful update for [redacted].dy.fi
Opening database /var/lib/ddns.db

[Third time I got that error]
Running on distribution: ipfire-2
Loading configuration file /var/ipfire/ddns/ddns.conf
Updating [redacted].dy.fi forced
Sending request (GET): https://checkip4.dns.lightningwirelabs.com
Request header:
  User-agent: IPFireDDNSUpdater/014
  Pragma: no-cache
Dynamic DNS update for [redacted].fi (dy.fi) threw an unhandled exception:
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 276, in get_address
    return self.__addresses[proto]
KeyError: 'ipv4'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3.10/http/client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/usr/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
TimeoutError: _ssl.c:980: The handshake operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/ddns/__init__.py", line 178, in _update
    entry(force=force)
  File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 162, in __call__
    self.update()
  File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 185, in update
    if self.have_address(protocol):
  File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 336, in have_address
    address = self.get_address(proto)
  File "/usr/lib/python3.10/site-packages/ddns/providers.py", line 329, in get_address
    return self.core.system.get_address(proto) or default
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 281, in get_address
    self._get_address(proto)
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 309, in _get_address
    local_ip_address = self.guess_external_ip_address(proto)
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 122, in guess_external_ip_address
    return self._guess_external_ip_address(url, **kwargs)
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 99, in _guess_external_ip_address
    response = self.send_request(url, timeout=timeout)
  File "/usr/lib/python3.10/site-packages/ddns/system.py", line 167, in send_request
    resp = urllib.request.urlopen(req, timeout=timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/usr/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/usr/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error _ssl.c:980: The handshake operation timed out>
Comment 7 Porkyle 2024-01-26 11:49:04 UTC
Created attachment 1454 [details]
another exeption

I was using 4G router in brideg mode and my internet connection went suddenly down. Checked DDNS log and there was new exeption, my ip hadn't changed and it wasn't yet time to update DDNS entry. Also noted that almost all DNS servers reported broken when checking servers, Error was timeout.

Then I run ddns update command from putty to get complete message.

After that I logged in router and switched bridge mode off. Internet connection started to work again and after that it worked again in bridged mode. My public IP didnt'n change. Maybe it's issue with router. 

Going to test older router soon. There are less connection issues if bridge mode is off and DMZ mode is used in router, but there are more exeptions in ddns log.

Exeption was little diffrent from the one that appeares when connection is working.