确定 RTSP 服务器是否为 运行 并且需要身份验证

Determining if an RTSP server is running and needs authentication

我知道某个 IP 地址的 554 端口(通常是 RTSP)是开放的。我希望能够确定:

我也想以尽可能轻便的方式来做这件事。我不需要访问视频流。

看完 RTSP 规范后,我意识到我可以简单地打开一个 TCP 套接字并发送以下命令:

OPTIONS * RTSP/1.0<CRLF>
CSeq: 1<CRLF>

当我在许多服务器上尝试这个时,我发现少数服务器响应

RTSP/1.0 200 OK
CSeq: 1
<a bunch of other stuff>

这是意料之中的事情。但是,我发出的大多数请求都超时了。这让我相信这些资源需要身份验证,或者我做的事情根本上是错误的。

我猜如果需要身份验证,大多数服务器都会以 401 响应,所以我可能做错了什么。有什么想法吗?

RTSP协议请参考RFC2326:RFC2326

D.1.2 Authentication-enabled

In order to access media presentations from RTSP servers that require authentication, the client MUST additionally be able to do the following:

 * recognize the 401 status code;
 * parse and include the WWW-Authenticate header;
 * implement Basic Authentication and Digest Authentication.