web-dev-qa-db-ja.com

デバッグ中のASP.NET CORE 2.1サーバーのタイムアウト

「エラー:サーバーからメッセージを受信せずにサーバーのタイムアウトが経過しました。」.

サーバー側のコードをデバッグしようとしていますが、その間、クライアントは1分未満で切断されます。

まだコントローラーなしで、SignalRを使用してクライアントと通信しています。

タイムアウトを無効にするか、少なくとも現在よりも長くすることができる設定はありますか?

私のlaunchSettings.json:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:26793",
      "sslPort": 44386
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_HTTPS_PORT": "44386"
      }
    },
    "Api": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_URLS": "https://localhost:5001;http://localhost:5000"
      }
    }
  }
}
11
Arhire Ionut

おかげで @ Arhire Ionut

JavaScriptクライアントのタイムアウトを増やす方法は次のとおりです

hubConnection.serverTimeoutInMilliseconds = 100000; // 100 second

詳細はこちら=> https://github.com/aspnet/Docs/issues/6885

7
Mahmoud Farahat

@MahmoudFarhatが別の答えで述べたことは正しいです。 しかし、このリンクも参照してください そして、以下の私のコメントを読んでください。

SignalRが切断された場合は、接続を再確立してみてください。ユーザー切り替えネットワークなど、他のいくつかの理由で接続が切断される可能性があります。たとえば、ユーザーが携帯電話を使用していて、自宅/オフィスのWifiに接続しているが、外に出ると携帯電話のデータ接続に接続する場合などです。

再接続するには、以下を使用できます(私にとっては魅力のように機能します)。

// re-establish the connection if connection dropped
connection.onclose(() => setTimeout(startSignalRConnection(connection), 5000));

ここで、startSignalRConnectionは:

const startSignalRConnection = connection => connection.start()
  .then(() => console.info('Websocket Connection Established'))
  .catch(err => console.error('SignalR Connection Error: ', err));

そして接続は

const connection = new HubConnectionBuilder()
  .withUrl(connectionHub, options)
  .withHubProtocol(protocol)
  .build();
7
xeiton