Попытка подключить приложение MVC к удаленному хосту по IP xxxxxxxxx

#c# #asp.net-mvc #postgresql #api

#c# #asp.net-mvc #postgresql #API

Вопрос:

Я пытался подключить мое приложение MVC к удаленному хосту по IP xxxxxxx.

но что за ошибка, которую я получаю, заключается в следующем :

 "InnerException": {
    "Message": "An error has occurred.",
    "ExceptionMessage": "The provider did not return a ProviderManifestToken string.",
    "ExceptionType": "System.Data.Entity.Core.ProviderIncompatibleException",
    "StackTrace": "   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)rn   at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)",
    "InnerException": {
        "Message": "An error has occurred.",
        "ExceptionMessage": "FATAL: 28000: no pg_hba.conf entry for host "210.7.22.121", user "user", database "postgres", SSL off",
        "ExceptionType": "Npgsql.NpgsqlException",
        "StackTrace": "   at Npgsql.NpgsqlState.<ProcessBackendResponses>d__0.MoveNext()rn   at Npgsql.NpgsqlState.ProcessAndDiscardBackendResponses(NpgsqlConnector context)rn   at Npgsql.NpgsqlConnectedState.Startup(NpgsqlConnector context, NpgsqlConnectionStringBuilder settings)rn   at Npgsql.NpgsqlConnector.Open()rn   at Npgsql.NpgsqlConnectorPool.GetPooledConnector(NpgsqlConnection Connection)rn   at Npgsql.NpgsqlConnectorPool.RequestPooledConnectorInternal(NpgsqlConnection Connection)rn   at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection Connection)rn   at Npgsql.NpgsqlConnection.Open()rn   at Npgsql.NpgsqlServices.UsingPostgresDBConnection(NpgsqlConnection connection, Action`1 action)rn   at Npgsql.NpgsqlServices.GetDbProviderManifestToken(DbConnection connection)rn   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)"
  

Но этот ip 210.7.22.121 является моим IP localmachine, и он также неправильно отображает имя базы данных. Я пытаюсь подключить мое приложение MVC к этому удаленному хосту по IP xxxxxx :

Ниже приведен мой web.config :

 <?xml version="1.0" encoding="utf-8"?>

<configuration>
  <configSections>
    <section name="entityFramework" 
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>

  <connectionStrings>
    <add name="ibp_live3" connectionString="server=xxxxx.xxxx.xxxx;user id=xxxxx;password=xxx;database=xxxx" providerName="Npgsql" />

  </connectionStrings>
  <entityFramework>

    <providers>
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />

    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Npgsql" />
      <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
    </DbProviderFactories>
  </system.data>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1" />
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.12.0" newVersion="2.0.12.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=amp;quot;Webamp;quot; /optionInfer " />
   </compilers>
  </system.codedom>
  <system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>




</configuration>
  

Комментарии:

1. Вы уверены, что ваша база данных прослушивает этот интерфейс?

2. Сообщение об ошибке ясно: ... no pg_hba.conf entry for host ... Это означает, что сервер не имеет конфигурации для приема подключений с вашего IP. По умолчанию PostgreSQL настроен путем внесения в белый, а не в черный список. Это означает, что вы должны добавить разрешенные клиенты в pg_hba.conf файл, как описано здесь: postgresql.org/docs/current/auth-pg-hba-conf.html

3. Спасибо, я попросил администратора хоста сервера внести в белый список IP-адрес моего локального компьютера. сообщит, работает ли это