首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Delphi mORMot无法连接,因为目标机器主动拒绝它

Delphi mORMot无法连接,因为目标机器主动拒绝它
EN

Stack Overflow用户
提问于 2015-09-07 11:14:50
回答 1查看 804关注 0票数 0

我测试mORMot组件。我编写了standart演示"28 -简单的RESTful ORM“,运行它并得到一个错误。

代码:

代码语言:javascript
复制
var
  aModel: TSQLModel;
  aProps: TSQLDBConnectionProperties;
  aRestServer: TSQLRestServerDB;
  aHttpServer: TSQLHttpServer;
begin
// set logging abilities
SQLite3Log.Family.Level := LOG_VERBOSE;
//SQLite3Log.Family.EchoToConsole := LOG_VERBOSE;
SQLite3Log.Family.PerThreadLog := ptIdentifiedInOnFile;
// ODBC driver e.g. from http://ftp.postgresql.org/pub/odbc/versions/msi


aProps := TODBCConnectionProperties.Create('','Driver=PostgreSQL Unicode'+
  {$ifdef CPU64}'(x64)'+{$endif}';Database=postgres;'+
  'Server=127.0.0.1;Port=5433;UID=postgres;Pwd=postgres','','');

//readln;

try
// get the shared data model
aModel := DataModel;
// use PostgreSQL database for all tables
VirtualTableExternalRegisterAll(aModel,aProps);
try
  // create the main mORMot server
  aRestServer := TSQLRestServerDB.Create(aModel,':memory:',false); // authentication=false
  try
    // optionally execute all PostgreSQL requests in a single thread
    aRestServer.AcquireExecutionMode[execORMGet] := amBackgroundORMSharedThread;
    aRestServer.AcquireExecutionMode[execORMWrite] := amBackgroundORMSharedThread;
    // create tables or fields if missing
    aRestServer.CreateMissingTables;
    // serve aRestServer data over HTTP
    aHttpServer := TSQLHttpServer.Create(SERVER_PORT,[aRestServer],'+',useHttpApiRegisteringURI);
    try
      aHttpServer.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
      writeln('Background server is running.'#10);
      write('Press [Enter] to close the server.');
      readln;
    finally
      aHttpServer.Free;
    end;
  finally
    aRestServer.Free;
  end;
finally
  aModel.Free;
end;
finally
  aProps.Free;
end;
end.

错误

{“消息”:“TODBCLib错误: 08001无法连接到服务器;\n由于目标计算机主动拒绝连接而无法连接。\r 127.0.0.1:5433

如何清除它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-07 12:11:02

我刚刚用Delphi西雅图10和来自0400.zip的ODBC驱动程序测试了它--没有问题。

确保您的PostgreSQL服务器已定义为运行在源所期望的相同端口上。如果使用默认端口号,则将5433值编辑为5432

由于偏执,我总是试图更改默认端口,这减少了网络扫描攻击(至少从快速扫描)。我从不对ssh使用端口22,对PostgreSQL使用端口5432。很抱歉给您带来不便。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32437332

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档