我有一个简单的客户端服务器应用程序使用WCF(netTcpBinding)当我启动服务器并通过客户端发送消息时,每件事都可以正常工作,但是当我手动关闭服务器并再次打开它时(不关闭客户端应用程序)所有)下次客户端尝试向服务器发送消息时,我得到此异常(在客户端):
套接字连接已中止.这可能是由于我们的消息处理错误或远程主机超出接收超时或者网络资源问题造成的.本地套接字超时为'00:00:59.9843903'.
如果我使用basicHttpBinding,则不会发生问题.
是谁知道为什么会出现这个问题??? 谢谢,丽然
我正在尝试从IIS中运行两个WCF服务,一个是Web服务,另一个是Net TCP绑定服务。
这是我的Web.config的一个类似物(我已将服务名称匿名化):
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="ServerService">
<endpoint address="ServerService"
binding="netTcpBinding"
bindingConfiguration=""
name="NetTcpEndPoint"
contract="IServerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/"/>
<add baseAddress="htt://localhost:8523/"/>
</baseAddresses>
</host>
</service>
<service name="MyWebService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration=""
name="AACCWSEndPoint"
contract="IMyWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8523/IMyWebService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and …Run Code Online (Sandbox Code Playgroud) 我有nettcpbinding服务并使用Windows服务托管它.该服务必须在网络上工作,它处理来自100多个客户端的传入消息.
问题:我想拥有一个所有会话都可以访问它的属性.像这样 :
class a
{
list<string> strList=new list<string>();
class b{}
class c{}
...
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,所有类都可以访问strList.我希望有一个列表,所有会话都可以访问它(添加或删除该列表中的东西).
服务配置是缓冲的,没有安全性.和服务属性在这里:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
[ServiceContract(SessionMode = SessionMode.Required)]
Run Code Online (Sandbox Code Playgroud)
编辑: 我不想创建那些只是一个例子的类.我只需要一个列表,所有会话都可以访问它.当你有服务类将为每个客户端创建的InstanceContextMode.PerSession服务,然后每个客户端都有自己的服务类现在我希望每个创建的会话可以访问一个公共列表.
EDIT2: 此列表在服务器中,只是服务器可以访问它不需要发送列表到客户端.它是用于计算某些东西的服务器变量.
我正在尝试部署一个WCF服务,该服务在远程服务器(Win 2008 R2)上使用netTcpBinding(以及mexTcpBinding用于元数据)而不安装IIS.
麻烦的是,我正在尝试的一切都告诉我,我需要在远程盒子上安装各种IIS组件.
那是真的吗?在我看来,使用tcp.net连接,没有IIS我应该没问题.
我遇到了一个非常奇怪的问题.我正在构建一个分布很广的应用程序,其中每个应用程序实例可以是WCF服务的主机和/或客户端(非常像p2p).一切正常,只要客户端和目标主机(我指的是应用程序,而不是主机,因为目前一切都在一台计算机上运行(所以没有防火墙问题等))不一样.如果它们是相同的,那么应用程序挂起正好1分钟,然后抛出TimeoutException.WCF-Logging没有产生任何帮助.这是一个小应用程序,它演示了这个问题:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
var binding = new NetTcpBinding();
var baseAddress = new Uri(@"net.tcp://localhost:4000/Test");
ServiceHost host = new ServiceHost(typeof(TestService), baseAddress);
host.AddServiceEndpoint(typeof(ITestService), binding, baseAddress);
var debug = host.Description.Behaviors.Find<ServiceDebugBehavior>();
if (debug == null)
host.Description.Behaviors.Add(new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true });
else
debug.IncludeExceptionDetailInFaults = true;
host.Open();
var clientBinding = new NetTcpBinding();
var testProxy = new TestProxy(clientBinding, new EndpointAddress(baseAddress));
testProxy.Test();
}
}
[ServiceContract]
public interface ITestService
{
[OperationContract] …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个wcf服务,以便在IIS 7上使用net.tcp.
这是我得到的错误:
在net.tcp://127.0.0.1:8000/ListingService中没有可以接受该消息的端点监听.这通常是由错误的地址或SOAP操作引起的.有关更多详细信息,请参阅InnerException(如果存在).
这是我从客户端调用的代码:
using (var client = new ListingServiceClient("NetTcpBinding"))
{
client.Test();
client.Close();
}
Run Code Online (Sandbox Code Playgroud)
这是我的服务web.config - http://pastebin.com/3S8BZbup
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<!--throttle service-->
<serviceThrottling
maxConcurrentCalls="10000"
maxConcurrentSessions="10000"
maxConcurrentInstances="10000" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="default" name="Housters.Services.ListingService">
<endpoint name="TcpEndpoint"
address="net.tcp://127.0.0.1:8000/ListingService"
binding="netTcpBinding"
contract="Housters.Services.IListingService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
这是我的客户端app.config - http://pastebin.com/YpiAhh46
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings> …Run Code Online (Sandbox Code Playgroud) 我想从iPhone上使用.NET编写的web服务,它使用wsdl中的NetTcpBinding显示.是否可以从iphone中使用除BasicHttpBinding之外的web服务?如果可能的话,我该如何消费呢?
有人可以帮助netTcpBinding v/s BasicHttpBinding之间的主要区别是什么?
在我当前的项目中,我们将BasicHttpBinding转换为netTcpBinding并获得性能问题,即使BizTalk中的值设置为1:00:00,它也会启动超时.我们无法弄清楚为什么?