rfancn / aliyun-ddns-client

Python DDNS client for Aliyun
402 stars 137 forks source link

Failed to Update #6

Closed fjrsama closed 7 years ago

fjrsama commented 7 years ago

Got the error returned from dns.aliyun.com: image

The parameters: image

Call stack: image

rfancn commented 7 years ago

pls paste out the ddns.conf here, it seems may be some invalid value specified for 'Type'/'RR'/'Line'/'Value', make sure there is no "''" for type value set in ddns.conf, e,g: A is good, 'A' is bad.

fjrsama commented 7 years ago

thanks for reply image It works well in the past few months on my raspberry pi until yesterday, there's no changes to the ddns.conf at all.

rfancn commented 7 years ago

From the error info, server returned 400 bad request error which indicate one of following parameters is invalid: RR, Type, Line, Value. As no changes had been done in client side recently, I think this may be server side issue. I suggest you capture the HTTP packet it send to server and compare with what works well on desktop, or just wait for sometime to see it become ok or not.

fjrsama commented 7 years ago

I've checked, There's no problem in HTTP packet. After further investigation, I found how to 100% reproduce this error:

  1. Open a terminal, ping your domain to see your domain IP, mark as IP1.
  2. log on aliyun console page to see the IP which your domain points to, mark as IP2.
  3. Open ddns.conf to see the stored IP, mark as IP3.
  4. Make sure IP1 == IP2, if not, just wait some time for them to sync.
  5. Modify IP3, make sure IP3 != IP2. or IP3 = null
  6. Run ddns.py, then the error comes.

I encountered this issue because yesterday I manually modify ip2 at console page, causing IP1==IP2!=IP3. So the solution is, modify ip3, make sure ip3 == ip2 and never, ever, ever manually modify ip2 again, then the problem resolved. But still I don't know why this is happening.

rfancn commented 7 years ago

I tried to reproduce the similar issue as what you said, but failed. so I tried to add duplicate domain records in Aliyun via console, e,g:

  1. there already exist a domain with 'www.test.com' with value: 192.168.0.1,
  2. then add another domain with same name 'www.test.com' with value: 192.168.0.2
  3. run ddns.py
  4. delete one of them
  5. run ddns.py

The issue can be 100% reproduced, this kind of error reported by Aliyun server, sometimes it reported as "The specified value is not valid", sometimes it reported as "The domain record is duplicated". Basically, the root cause is ddns client send the unmatched record id when invoking updateDomainRecord().

I don't know how you triggered this issue, I suppose you accidentally added a duplicate entry in Aliyun console, then removed it later. in fact, the remote domain record id was changed after you doing above, but the local record id saved in /etc/ddns.conf is still the old one.

Anyway, the code logic need improved to avoid this corner case. I already patched the related codes, pls see if you can still reproduce it or not.

BTW: if you does some actions like add/remove some domain records in Aliyun console, it had better clear the corresponding domain record's value in /etc/ddns.conf, which can forcefully sync remote domain record id to local domain id. For performance purpose, normal syncing operation will not touch the saved locate record id.