クライアントからサービスに大きなバイナリ ファイルを送信できる WCF サービスを構築しようとしています。
ただし、最大 3 ~ 4 MB のファイルしか正常に転送できません。(4.91MB を転送しようとすると失敗します。もちろん、それ以上のものは転送できません)
4.91MB のファイルを送信しようとすると、次のエラーが表示されます。
例外メッセージ: http://localhost:56198/Service.svcへの HTTP 応答の受信中にエラーが発生しました。これは、サービス エンドポイント バインディングが HTTP プロトコルを使用していないことが原因である可能性があります。これは、HTTP 要求コンテキストがサーバーによって中止されたことが原因である可能性もあります (サービスのシャットダウンが原因である可能性があります)。詳細については、サーバー ログを参照してください。
内部例外メッセージ:基になる接続が閉じられました: 受信時に予期しないエラーが発生しました。
内部例外メッセージ:トランスポート接続からデータを読み取ることができません: 既存の接続がリモート ホストによって強制的に閉じられました。
内部例外メッセージ:既存の接続がリモート ホストによって強制的に閉じられました
このエラーは、公開されたサービス メソッドにメソッド パラメータとして byte[] ファイルが送信されるとすぐに、クライアント側で発生します。
サービス メソッドの最初の行にブレークポイントがあります。ファイル転送が成功した場合 (3MB 未満)、ブレーク ポイントにヒットしてファイルが転送されます。ただし、この場合、メソッドが呼び出されるとすぐにエラーが発生します。このエラーの場合、サービスのブレークポイントはヒットしません。
Service Web.config と Asp Page (Client) Web.config のセクションを貼り付けます。ファイルを送信してファイルを受け入れるコードも必要な場合は、お知らせください。それも送信します。
サービス Web.Config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpEndpointBinding" closeTimeout="01:01:00"
openTimeout="01:01:00" receiveTimeout="01:10:00" sendTimeout="01:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="StreamedRequest"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646"
maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="DragDrop.Service.ServiceBehavior" name="DragDrop.Service.Service">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpEndpointBinding" contract="DragDrop.Service.IService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DragDrop.Service.ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
クライアント (Asp.net ページ) Web.Config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="StreamedResponse"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646"
maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="debuggingBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost:56198/Service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService" contract="ServiceReference.IService"
name="BasicHttpBinding_IService" behaviorConfiguration="debuggingBehaviour" />
</client>
</system.serviceModel>