LoginSignup
5

More than 5 years have passed since last update.

SQL Server + .NET で Timeout expired. というエラーが出る

Last updated at Posted at 2017-12-01

#別blogから引っ越した2013/12/12の記事です。

いきなり技術記事ですが、この事象で日本語の記事がなかなか見つからなかったため、同じような問題に困っている方に向けて書き残しておこうと思います。

当社のインフラはAWSに Windows Server 2012 + .Net + SQL Serverを構築して動いていますが、一定の割合で下記のような例外が発生していました。

System.Data.SqlClient.SqlException (0x80131904): A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.) ---> System.ComponentModel.Win32Exception (0x80004005): The semaphore timeout period has expired

System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

原因がわからず、Google先生にすがりついたところ、以下のAWSフォーラム投稿を発見しました。

[RDS + .Net]Semaphore timeout error when cnnecting to a db instance

これによると、答えは以下の部分でした。

some settings on the NIC
IPv4 checksum offload - disable
large receive offload - disable
large send offlaod - disable
tcp checksum offload - disable

英語に疎いものでなぜこうなのかをきちんと理解しきれていませんが、試してみたところ見事に掲題のエラーは収束することができました。

設定するにはコントロールパネルなどからネットワーク設定へ進み、イーサネットアダプタの詳細設定を開きます。

image.png

この中から記事の通りにNICプロパティ4つをDisabledに変更します。

 ・IPv4 Checksum Offload

 ・Large Receive Offload(IPv4)

 ・Large Send Offload Version(IPv4)

 ・TCP Checksum Offload(IPv4)

さすがにNICの変更のためRDPは瞬断しましたが、数秒で再接続されました。

OSの再起動は発生しません。

設定後は .Netの例外は収束し、サーバも安定しているようです。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5