【发布时间】:2019-08-23 09:17:20
【问题描述】:
我有一个稳定的 Delphi 10.2.3 TCP/IP Datasnap 服务器和客户端,在 99.9% 的时间里都能正常工作。有时,用户会收到“10054 Connection reset by peer”错误。我使用Eurekalog,调用堆栈报告显示错误发生在生成的ClientClassesUnit 中的DBXCommand.Prepare 语句中:
function TServerMethods3Client.UpdateTask(ID: Integer): Boolean;
begin
if FUpdateTaskCommand = nil then
begin
FUpdateTaskCommand := FDBXConnection.CreateCommand;
FUpdateTaskCommand.CommandType := TDBXCommandTypes.DSServerMethod;
FUpdateTaskCommand.Text := 'TServerMethods3.UpdateTask';
FUpdateTaskCommand.Prepare; // --> exception is raised here
end;
FUpdateTaskCommand.Parameters[0].Value.SetInt32(ID);
当然,与Datasnap服务器的连接是在calll to server方法之前实现的,使用通常的方式:
SQLConnection1.Connected := True
Server := TServerMethods3Client.Create(SQLConnection1.DBXConnection);
try
Result := Server.UpdateTask(CDSTask.FieldByName('ID').AsInteger)
问题不在于连接到服务器失败,而在于连接没有“保持正常”,甚至没有几毫秒。
感谢任何cmets。
【问题讨论】: