<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 </head><body style=""><div>Hello Ross</div>
<div> </div>
<div>Using LIVE555 as a client to receive RTSP/RTP/MPEG2-TS streams from a 3rd party RTSP server, I've encountered a problem which I'm hoping can be easily fixed.</div>
<div> </div>
<div>Sequence for reproducing is as follows...</div>
<div> </div>
<div>1. Use LIVE555 RTSP client to send a SETUP request:</div>
<div> </div>
<div>SETUP rtsp://172.31.0.1:554/stream1760952/ RTSP/1.0<br>CSeq: 2<br>User-Agent: LIVE555 Streaming Media v2015.07.31<br>Transport: RTP/AVP;unicast;client_port=62392-62393<br><br></div>
<div>2. The 3rd party server responsds:</div>
<div> </div>
<div>RTSP/1.0 200 OK<br>CSeq: 2<br>Session: 3621155123<br>Blocksize: 15452<br>Transport: RTP/AVP;unicast;client_port=62392-62393;server_port=5001-5002<br>Server: DOTS 2.0 UPnP/1.0 ATI TV Wonder OpenCable Receiver (37F0), Unit #1/(null)<br>CONNECTION: Close<br>CACHE-CONTROL: no-cache<br><br></div>
<div>So far so good.</div>
<div> </div>
<div>3. Attempt to use LIVE555 RTSP client to send a PLAY request:</div>
<div> </div>
<div>PLAY rtsp://172.31.0.1:554/stream1760952/ RTSP/1.0<br>CSeq: 3<br>User-Agent: LIVE555 Streaming Media v2015.07.31<br>Session: 3621155123<br>Range: npt=0.000-<br><br></div>
<div> </div>
<div>==> LIVE555 returns error code -10057 (-WSAENOTCONN).</div>
<div> </div>
<div> </div>
<div>After some investigation I think I've discovered the cause of the problem.</div>
<div> </div>
<div>The connection header in the SETUP response indicates that the server expects LIVE555 to close its socket on reception of that response. However LIVE555 currently does not handle the connection header, and therefore doesn't close its socket. When asked to send the PLAY request, LIVE555 almost always attempts to reuse the same [closed] socket. Since the server has closed its end of the socket, the PLAY request fails. Occasionally when LIVE555 coincidentally sends the PLAY request on a newly connected socket, the request succeeds and the RTP stream can connect.</div>
<div> </div>
<div>The following patch seems to be an effective solution:</div>
<div>(RTSPClient.cpp line 1745)</div>
<div>    } else if (checkForHeader(lineStart, "Connection:", 11, headerParamsStr)) {<br>      if (_strncasecmp(headerParamsStr, "Close", 5) == 0) {<br>        resetTCPSockets();<br>      }<br>    }</div>
<div> </div>
<div> </div>
<div>If you consider this solution to be appropriate, please would you consider accepting this patch.</div>
<div> </div>
<div>Thanks and regards,</div>
<div>Nathan</div></body></html>