Доброй ночи. Может кто сталкивался с такой проблемой.
При попытке подключиться через интернет по net.tcp возникает ошибка:
"The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9629979'."
Inner Exception: "Удаленный хост принудительно разорвал существующее подключение".
Подключение к этому же сервису извне по http(basic) работает. В локальной сети оба способа работают отлично.
Сервис хостится на IIS 7
Привязки IIS на сервере
http -1342
net.tcp -1343
На сервере маппирование портов:
1342(внутренний)->61342(внешний);
1343(...)->61343(...);
При генерации прокси-классов с удалённого сервера в app.config добавляются конечные точки:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IContractorServiceWCF1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="NetTcpBinding_IContractorServiceWCF1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="http://<домен>:61342/clw/WCFContractors/ContractorServiceWCF.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IContractorServiceWCF1"
contract="ServiceReference1.IContractorServiceWCF" name="BasicHttpBinding_IContractorServiceWCF" />
<endpoint address="net.tcp://<локальное_имя_сервера>.<домен>:1343/clw/WCFContractors/ContractorServiceWCF.svc"<!--почему именно так?-->
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IContractorServiceWCF1"
contract="ServiceReference1.IContractorServiceWCF" name="NetTcpBinding_IContractorServiceWCF1" />
</client>
</system.serviceModel>
Заменяю address="net.tcp://<локальное_имя_сервера>.<домен>:1343/clw/WCFContractors/ContractorServiceWCF.svc" на address="net.tcp://<домен>:61343/clw/WCFContractors/ContractorServiceWCF.svc"
И при запуске приложения получаю эту ошибку
Код
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
static void Main(string[] args)
{
using (ContractorServiceWCFClient client = new ContractorServiceWCFClient("NetTcpBinding_IContractorServiceWCF1"))
{
//client.State - Faulted
DataSet ds = client.GetContractors();//!ошибка "The socket connection was aborted. This could be caused by an error processing your message or a receive..."
foreach (DataRow s in ds.Tables[0].Rows)
Console.WriteLine(String.Format("{0} - {1}", s["id"],s["name"]));
Console.ReadLine();
}
}
Конфиг на IIS
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
...
</configSections>
<system.web>
...
</system.web>
<applicationSettings>
<CSWebServices.Properties.Settings>
<setting name="Setting" serializeAs="String">
<value />
</setting>
</CSWebServices.Properties.Settings>
</applicationSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ContractorsHttpBinding" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
<netTcpBinding>
<binding name="ContractorsNetTcpBinding" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="CSWebServices.WCFContractor.IContractorServiceWCF">
<endpoint binding="basicHttpBinding" bindingConfiguration="ContractorsHttpBinding"
contract="CSWebServices.WCFContractor.IContractorServiceWCF" />
<endpoint binding="netTcpBinding" bindingConfiguration="ContractorsNetTcpBinding"
contract="CSWebServices.WCFContractor.IContractorServiceWCF" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
...
</system.webServer>
</configuration>
Как правильно настроить wcf-сервис или сервер приложений чтобы можно было работать по net.tcp через интернет?