Story: In a client-server system I use a long time connection(an http(s) request from client to server with a long time timeout) in order to use notify client to do some actions(Most of data transfer is from client to server but some commands send to client in response of this http(s) request).
Problem: If client cancel the connection server can understand that but if internet connection of client loses(e.g, unplug the LAN cable or it loses the WLAN/GPRS antenna) neither client nor server understand this. Connection still remains until (some time spends and) somebody writes something in it which is too late.
PS: 0) I googled with AKC/NACK
, Keep-alive
, ping-pong
and heartbeat
key words for http(s) request and could not find a protocol which it periodically check the status of request.
1) In this you can find an argument for curl
command which sets a time interval to send a props(also I monitored this with wireshark). But if still if you unplug the cable neither curl
command nor server
can understand the connection lost.
curl -k --keepalive-time 5 https://exampel.com/v1/v/f9a64e73/notification
2) Also here explains that there is an http header which is used to use a connection multiple time.
In server side and with nginx
web-server we can enable TCP keep-alive probe with so_keepalive=on
as listen
input argument. Find more information in this link.