Delphi Indy HTTPS Web 服务器错误(观察到违反协议(protocol)的 EOF)

标签 delphi ssl indy indy10

我正在尝试使用 Indy 向使用 Delphi XE7 编写的现有 Web 服务器添加 HTTPS 支持。我编写了一个简单的应用程序,它只在每个 HTTPS 请求上返回一个日期/时间戳。

我向 OnCommandGetOnException 事件添加了处理程序:

procedure TForm13.HTTPServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
  AResponseInfo.ContentText := DateTimeToStr(Now());
  AResponseInfo.ContentEncoding := 'utf8';

  Log('Request: %s', [ARequestInfo.URI]);
end;

procedure TForm13.HTTPServerException(AContext: TIdContext; AException: Exception);
begin
  Log('Exception raised %s:%s', [AException.ClassName, AException.Message]);
end;

绑定(bind)代码:

  with HTTPServer do
   begin
     with Bindings.Add() do
      begin
        IP := '0.0.0.0';
        Port := 443;
      end;

     Active := true;
   end;

当我执行来自浏览器的请求时,在大多数情况下我会得到:

12.03.2019 0:50:29  Exception raised EIdConnClosedGracefully:Connection Closed Gracefully.
12.03.2019 0:50:29  Exception raised EIdConnClosedGracefully:Connection Closed Gracefully.
12.03.2019 0:50:30  Request: /
12.03.2019 0:50:30  Exception raised EIdConnClosedGracefully:Connection Closed Gracefully.
12.03.2019 0:50:30  Request: /favicon.ico
12.03.2019 0:51:00  Exception raised EIdSocketError:Socket Error # 10060    Connection timed out.

它处理请求并且浏览器显示时间戳。但为什么优雅的连接关闭会引发异常?

更让我困扰的是,有时在最后一次请求后 30 秒后,我会得到另一个异常,如下所示:

12.03.2019 1:44:53  Exception raised EIdConnClosedGracefully:Connection Closed Gracefully.
12.03.2019 1:44:53  Exception raised EIdConnClosedGracefully:Connection Closed Gracefully.
12.03.2019 1:44:53  Request: /
12.03.2019 1:44:54  Exception raised EIdConnClosedGracefully:Connection Closed Gracefully.
12.03.2019 1:44:54  Request: /favicon.ico
12.03.2019 1:45:24  Exception raised EIdOSSLAcceptError:Error accepting connection with SSL. EOF was observed that violates the protocol

它是随机发生的,有时是超时,有时是这个。这对我来说看起来不对。知道为什么会这样吗?

PS:在 Delphi 10.3 中它的发生方式与在 Delphi XE7 中相同,因此可能所有 Indy 版本都会受到影响。

最佳答案

最后发现所有这些奇怪的错误只有在客户端设备上没有安装自生成证书的情况下才会出现。

关于Delphi Indy HTTPS Web 服务器错误(观察到违反协议(protocol)的 EOF),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55112571/

相关文章:

delphi - TVirtualDrawTree - 如何将节点放置在一行中?

delphi - 在 Delphi 中调整 png 图像大小 - 不正确的 alpha channel

powershell - 使用 powershell 连接到 HTTPS 站点

android - CSE(自定义搜索引擎)步骤

docker - 使用 traefik 将 ssl 路由到不同 docker 上的不同服务器

delphi - 具有恢复支持的 Indy Http Server

delphi - Indy TCP Server 无法通过服务工作?

delphi - 用Delphi绘制和清除桌面 Canvas

linux - TIdSMTPServer 和 TIdPOP3Server 无法在 UBUNTU LINUX 中启动

postgresql - FireDAC:如何避免 "Cannot describe type"错误? (在 postgres 几何列上)