W5500 DNS Timeout Issue
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: W5500 DNS Timeout Issue
by Eugeny ·
Probably related to something like the Cisco’s “fast-start” port option. Dig into the router manual. You goal is to make port ready at the router’s side as fast as possible when link is up from W5500 side.
RE: W5500 DNS Timeout Issue
by pspeirs ·
I’ll have a look at that side also, although that doesn’t really explain why the first lookup is successful. I did try leaving the unit alone for around 10 minutes or so in case it was some strange timing thing. Same behaviour where the first lookup works, 2 and 3 return error and subsequent lookups are fine.
RE: RE: W5500 DNS Timeout Issue
by Eugeny ·
First request may go through because port startup settings match the line and before router starts port training. This is a guess of course, but it somehow may explain the behavior. On normal steady link situations like yours must not happen.
RE: W5500 DNS Timeout Issue
by pspeirs ·
I think I’ve eliminated the port as the reason for failure. It was orginally connected to an old cisco switch to the router. I tried directly connected to the router (interestingly faster obtaining an IP address) with the same result and then to a check switch and still had issues.
It isn’t making a lot of sense so far, the only other thing I can look at is putting the old router back in as a test but not looking forward to doing that
A short log view shows exactly the same pattern each time I run the program. I’m using some buttons to instigate the DNS call.
First attempt work, the next two fail and then works from that point on. Interestingly, on the failures it still returns the correct IP address for that domain.
Cheers,
Paul
RE: W5500 DNS Timeout Issue
by pspeirs ·
I just pulled the tcp traffic off the router and this confirms that the request/response seems fine. Each reply contains the DNS result as shown in the attached file. I’m tending back towards the code but that isn’t making a lot of sense either.
dns_packets.zip (507 Bytes)
RE: W5500 DNS Timeout Issue
by Eugeny ·
Agree, packets are ok. What is the version of library? Please ensure you use the latest as it seems there were bugs fixed throughout code life. Library does not cover calling
DNS_time_handler(), which is expected to count seconds, and by defaultDNS_WAIT_TIMEis 3 (3 seconds) andMAX_DNS_RETRYis 2 (two attempts). We see two attempts, but does the timing of each attempt match (3 seconds)?RE: W5500 DNS Timeout Issue
by pspeirs ·
Yes, the timing is correct with 2 retries of 3 seconds, athough it appears that I’ve solved the issue.
The ports are allocated by a function in w5500_iface.c that were added I believe by my Nigerian programmer (yeah, there is one :-)) as we were havig issues with port allocations at one point, so was changed to the following:
anything requiring a port was calling this function . . . although not everything.
socket.c had the following in case the port wasn’t send in for whatever reason, and it was allocating, you guessed it, 2 ports on startup.
So the fix was to simply call the function w5500_get_unused_port(); in w5500_iface.c to ensure duplicate ports were not being issued. I’m not sure how far away from the original code this is, I don’t think it’s far off from a quick check, however certain mods were required to make everything work.
So, bottom line, mystery solved.
OK, one coffee later and thinking about it a little more it seems that if the two ports allocated on startup (and I suspect without checking that they are DHCP and NTP clients) are not being closed, then this issue will eventually happen twice at some point in the future when the cycle comes around again.
My project is current hosting a webserver for configuration, and clients for DHCP, NTP, Syslog, DNS and MQTT so there’s a bit going on.
So, should ports ALWAYS be closed when the call has been made or should those allocated be tracked somehow as they’re allocated and released. When allocating a port one would do a lookup to see if a port in the pool is currently in use. Seems like effort compared to just closing the port.
RE: RE: W5500 DNS Timeout Issue
by Eugeny ·
Good to hear!
I am not closely familiar with the library and how it actually performs; on the lowest socket level it is wise to open socket, perform task, and close and release the socket if it is not needed on regular basis and you are short on sockets. W5500 has limited number of sockets, so it is up to you as system designer to decide if sockets hijacked for e.g. NTP or MQTT are always allocated, if you perform NTP sync regularly and use MQTT broker connecting regularly. In this example you have two less sockets for other operations.