Timeout and disconnect SBL2E

Discussion to talk about software related topics only.
Post Reply
hllopla
Posts: 1
Joined: Fri Sep 02, 2016 8:47 am

Timeout and disconnect SBL2E

Post by hllopla »

Hello.

I am using SBL2E in my design. A microcontroller is sending kind of heartbeat messages every 15 seconds to usart at SBL2E. When there is a problem in the network so socket cannot close properly from the client side, the SBL2E does not timeout and disconnect properly, even if I physically disconnect the connector, the SBL2E does not close the connection. Then, when I try to connect again SBL2E always rejects connection. I have to power off and on, or submit new setting using internal webserver to be able to connect again. This closes active connection so I can reconnect intermediately.
I guess my heartbeat messages from microcontroller to SBL2E keep connection alive, even if they cannot be transmitted on the TCP/IP side.
I was expecting SBL2E to be able to handle TCP/IP connection problems and reset socket connection based on "Timeout and disconnect after this many seconds of inactivity" parameter at internal webserver index page.

Am I doing something wrong? Is this behavior normal?

Thanks for your help.
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Timeout and disconnect SBL2E

Post by rnixon »

What you are encountering is called a half-open socket and is a common problem with tcp. If two hosts have an established tcp connection, and no data is being sent at the time a client crashes or there is a network problem, the other client has no way of knowing the first client had a problem, and the connection will stay open forever unless you have something in your code to do the timeout and call the close function.

So use something like a readwithtimeout or whatever makes send in your app to close the socket if no data has been sent/received for the time period you desire.
Post Reply