Socket is stuck in FIN_WAIT (0x18) state.
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: Socket is stuck in FIN_WAIT (0x18) state.
by Eugeny ·
I guess that your server wants to close the socket after communication is over at its side, sends FIN packet to “properly” disconnect, and never receives FIN/ACK back from the client.
The solution is simple and ugly. You perform DISCON command, wait until it completes, and then perform CLOSE command - and the socket is freed. If remote client will send FIN/ACK back, or will try to talk to the socket, it will get RST packet - this is not a problem because your server is finished with the communicaton and this is in compliance to the TCP proto (if you care about a kind of broken communication process).
RE: Socket is stuck in FIN_WAIT (0x18) state.
by Maksim ·
Yes, rather you are right, I tested the server through a mobile phone, possibly due to a slow connection, the w5500 did not receive a response signal FIN.
As I wrote, I work through interrupts, and read the register Sn_IR
I understand w5500 set this flag after the client answers FIN?
RE: RE: Socket is stuck in FIN_WAIT (0x18) state.
by becky ·
Yes.
No, W5500 keep LISTEN state until client is connected.
RE: RE: Socket is stuck in FIN_WAIT (0x18) state.
by Eugeny ·
I suspect so.
After you send last byte to the client, you perform DISCON, wait until Sn_CR register clears (command was accepted) and then immediately perform CLOSE (and again wait for Sn_CR to become 0). And now you can reuse the socket.
RE: Socket is stuck in FIN_WAIT (0x18) state.
by Maksim ·
For such an event (client not to send the FIN packet) must not be called TIMEOUT?
RE: RE: Socket is stuck in FIN_WAIT (0x18) state.
by Eugeny ·
I think it must (I do not use interrupts in my implementations), but the depending on timeout set the socket may be hung for relatively long time, thus it is in server’s interests to properly free socket as early as possible (properly = informing client that it has finished by sending FIN packet on DISCON).
RE: Socket is stuck in FIN_WAIT (0x18) state.
by Maksim ·
Oh, that’s great, since it fits my system well. This happens, rarely enough, so I’m not very scared that the server will free up a bit later, the main thing is that it would free up and not freeze.
The only strange thing is that I have this processing, but for some reason it doesn’t help = ( RTR = 200 and RCR = 3 so that it should be released quickly enough.
How I can this situation be emulated? Can I send SYN,FIN packages manually?
RE: RE: Socket is stuck in FIN_WAIT (0x18) state.
by Mxyxixptlick ·
Since there are only 8 sockets available on the W5500, your code will work better if you dispense with some of the formality. I monitor socket statuses and if one is hung in a non-productive state like “FIN” for longer than 250 ms, I force it to close immediately.
RE: RE: Socket is stuck in FIN_WAIT (0x18) state.
by becky ·
First, we need to know why the client does not respond to the FIN packet. The client must send a FIN ACK in response to the FIN. If you do not respond to the FIN at all, the W5500 will timeout the FIN packet. But now no timeout occurs. If the client sends an ACK to the FIN and disconnects, you can use the keepalive function. This function sends a packet periodically. If there is no response from the peer, timeout occurs and the connection is disconnected. You can use the Keep alive function using the Sn_KPALVTR register.
RE: Socket is stuck in FIN_WAIT (0x18) state.
by Maksim ·
I started to see what was going wrong first caught retransmissions.
192.168.0.114 is wiznet, I fill the entire packet into the socket and give the send command why does it send the packet 2 (3 times) splits it into 3 segments? pack (5,6,7) and why send pack 8 ?
This is a json request dump 3 times
RE: RE: Socket is stuck in FIN_WAIT (0x18) state.
by Mxyxixptlick ·
Your server (.114) appears to send the response header (HTTP/1.1 200 OK) after the response body (142 bytes). They should be in the opposite order. Afterwards your server starts to close the socket by sending (FIN/ACK). The client (.63) responds to the body or header with an ACK (you may have missed the other ACK that should’ve been there due to slow sampling on your WireShark machine; if so, that’s the likely cause of the ‘out of order’ message.). Then the client sends a (FIN/ACK) to acknowledge the close socket request.
I’d reverse the order in which the response header and body are sent, and don’t close the socket if you want to continue to use it .
RE: Socket is stuck in FIN_WAIT (0x18) state.
by Eugeny ·
There seem to be generic logic mistake in how code behaves. Spurious retransmission @24 must not happen, and I am afraid it is W5500 driver instructs to send the data again for some reason.
RE: Socket is stuck in FIN_WAIT (0x18) state.
by Maksim ·
No, no, everything is correct with the order, the heading is sent first, then the body. I don’t know why Wireshark in the info column displays like this
I open pack header (№5 196 byte):
In this case, wiznet was connected to the computer via cable directly without switches and routers.
RE: Socket is stuck in FIN_WAIT (0x18) state.
by Eugeny ·
Wireshark shows:
RE: Socket is stuck in FIN_WAIT (0x18) state.
by Maksim ·
You about pack 5-7 ?