ngraziano / SharpRTSP

A RTSP handling library
Other
557 stars 182 forks source link

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. #63

Open sinhngoc2008 opened 4 years ago

sinhngoc2008 commented 4 years ago

I'm using ShartRTSP to connect to HIPCAM camera by rtsp protocol. The handshake of rtsp is so well and I receive packet from rtsp server. But around 1 or 2 minutes later SharpRTSP cannot get data from network. I try to print out the debug message and see that the SharpRTSP send GET_PARAMETER every timeout / 2 interval. But without OK message response , SharpRTSP continue to send GET_PARAMETER again and this cause the problem. Please take a look the debug message in the attached file. rtspinfo.txt

ngraziano commented 4 years ago

Hello, Some camera do not want GET_PARAMETER but instead need OPTION for keep alive.

If you are using the sample code in RtspClientExample/RTSPClient.cs, to use OPTION for keep alive you can remove the code from line 1050 to 1057 by the code from line 1061 to 1066. Or you can remove all the keep alive for try.

Another way to check is to use wireshark to capture an exchange with VLC to see what are the differences (if VLC is working ok).

RogerHardiman commented 4 years ago

I think you have found an issue in Sharp RTSP

NewCommand: Rtsp.Messages.RtspResponse
Headers: CSeq: 8
Headers: Server: Hipcam RealServer/V1.0
Headers: Session: eKoPfUYGRpb
Headers: 
The thread 0x3d18 has exited with code 0 (0x0).

When the camera sends a reply to the GET_PARAMETER message, there is an empty Header. This is probably poor data from the camera but it is possible SharpRTSP does not handle the empty Header properly.

Is it possible to get access to the camera please and then I can test some things from here.

Thanks Roger

sinhngoc2008 commented 4 years ago

I'm sorry, this is a private camera of a company, so I cannot public the url to you. the thing is Header of GET_PARAMETER response always null from starting, but it still keep the connection up to 2 minutes. I don't know why it disconnect in only 2 minutes.