W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
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 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by Eugeny ·
First check the circuit. Ensure that you used 49.9 Ohm resistors and not 49.9 kOhm resisotrs (for example). My suspicion is that device is having difficulties finding the simeslot on the TX wire to send the packet, and hangs on the loop CR clearing to 0. Try connecting W5500 to another network device (e.g. replace hub/switch, change port of the hub/switch). But it must be proven: compile the code with check points in the
send()function (outputting some characters to the diagnostic console or anywhere else where you can see them) to find out where code gets stuck.RE: RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by hamidreza maddah ·
Hello
I have the same situation, how can I specify " device is having difficulties finding the simeslot on the TX wire to send the packet" ?
Thanks
RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by dannypovolotski ·
The circuit looks ok, I will check of course, and also I will do check points. But it seems weird to me that DHCP and DNS are 100% reliable, not a single failure. I would imagine a hardware error would affect that too, no?
I can lease IP, and resolve DNS 100% of the time. It’s send() for TCP that gets stuck.
RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by dannypovolotski ·
Yeah, the circuit looks fine. 49.9 Ohm resistors are proper value.
It’s TCP that has a 50% failure rate… I’m gonna try to put checkpoints in send().
Am I wrong to assume that a hardware issue would result in failures with DHCP leasing and DNS resolution as well as TCP? DHCP/DNS work absolutely flawlessly.
RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by dannypovolotski ·
Yup, I did use the ioLibrary code from that GitHub repo! As I said, the behavior is super odd to me, because DHCP works 100%, DNS works 100% , but TCP hangs 50% of the time. I’m still debugging it, but was wondering if someone knows where to point me.
In my understanding if there was something wrong with the physical TX line, DNS & DHCP would hang just as much, am I wrong?
RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by dannypovolotski ·
So, after some debugging turns out it gets stuck on socket connect() and not send(). Specifically, it gets stuck inside this loop:
That’s the spot it ends up stuck at, about 50% of the time. (the rest of the time everything works great).
getSn_SRseems to be stuck onSOCK_SYNSENT, and never changes to anything else. Which is weird, because I have a value of 2000 for timeout and 8 for retries. So at the very least it should timeout?This is the relevant code in my application:
When it works, it works flawlessly, but when it doesn’t ,it reliably gets stuck on
connect, being stuck onSOCK_SYNSENT.RE: RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by Eugeny ·
For these values TCP timeout will be 31.8 seconds, see RCR section of the datasheet, it has this value calculated. You just need to wait a little more
As @Bong said it is most probably that some device located on the packet path filters out or loses the SYN/ACK return packet.
RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by acpie360 ·
Do you have timeout in your SPI read/write driver?
RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by Mxyxixptlick ·
I saw a similar issue while developing code for the W5500 and used WireShark to debug it. I found the problem was that the W5500 wasn’t seeing ARP responses from the wireless device (an old Linksys router running DD-WRT as a bridge) I was trying to connect to. I saw the ARP request from the W5500 repeated over and over, but there was no response. Never figured out if the problem was the LinkSys router or the ASUS-WRT Merlin-based router it was connected to. Sometimes it worked just fine, other times it didn’t. I’ve never seen this with any other device.
RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by dannypovolotski ·
I’m still having intermittent issues. Those issues are very weird. I’m opening two sockets at a time - same destination IP and everything. As before , there is 100% stability on DNS & DHCP, but sometimes it gets stuck on
connect(). When it does get stuck, I don’t understand why does the retry not help it? Sometimes after timing out, my code tries to open the connection again, but then it works. Most times the first socket connects without an issue, but the second one hangs. However that’s not every time.The behavior is very weird and not very predictable.
I’m not entirely sure how can DHCP & DNS be rock solid, but TCP connections so fickle. Also - why would one socket to the same IP (I made sure the ports are different e.t.c) open with more stability than two?
RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by dannypovolotski ·
It also seems like when it DOES get stuck, the loop is infinite. It never actually times out
… It gets stuck in an infinite loop somewhere in connect()
RE: W5500 get stuck on connect(), but only sometimes (infinite loop stuck on SOCK_SYNSENT)
by Eugeny ·
This is a complex issue and requires analysis of the wireshark having dump of packets travelling on the network and exact indication of where execution is stuck and why (may require modification of the WIZnet library you use to display debug info and status information).