WCF NetTcpBinding
服务端:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding portSharingEnabled="true" name="tcpbindingConfig">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
<!--<serviceMetadata httpGetEnabled="True" httpGetUrl ="http://localhost:8300/myEndpoint"/>-->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<!--<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/>-->
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="TWS.TcpService" behaviorConfiguration="serviceBehavior">
<endpoint address="" binding="netTcpBinding" contract="TWS.ITcpService" bindingConfiguration="tcpbindingConfig"/>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8299/TcpService"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
宿主:
http://www.bubuko.com/infodetail-325542.html
客户端:
string serviceUri = "net.tcp://localhost:8298/TcpService.svc";
NetTcpBinding tcpbinding = new NetTcpBinding(SecurityMode.None);
tcpbinding.MaxReceivedMessageSize = int.MaxValue;
tcpbinding.ReaderQuotas.MaxDepth = 32;
tcpbinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
tcpbinding.SendTimeout = TimeSpan.MaxValue;
tcpbinding.ReceiveTimeout = new TimeSpan(0, 10, 10);
EndpointAddress endpoing = new EndpointAddress(serviceUri);
using (ChannelFactory<ITcpService> chf = new ChannelFactory<ITcpService>(tcpbinding,endpoing)) {
ITcpService proxy = chf.CreateChannel();
string result=proxy.GetData(10000);
MessageBox.Show(result);
}
注意安全模式需要客户端与服务端匹配,否则会报错
System.ServiceModel.CommunicationException:“套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的....
WCF NetTcpBinding的更多相关文章
- WCF NetTcpBinding 由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作
背景:WindowsService + WCF + NetTcpBinding 之前一直使用http协议模式,改为net.tcp之后隔段时间出现:由于系统缓冲区空间不足或队列已满,不能执行套接字上的操 ...
- 如何在IIS中承载WCF NetTcpBinding 服务
这篇博客将介绍如何在IIS中承载NetTcpBinding的服务. 1. 首先准备服务代码. Contract namespace Contract { [ServiceContract] publi ...
- WCF : 如何将NetTcpBinding寄宿在IIS7上
摘要 : 从IIS 7 开始, IIS增加了对非HTTP协议的支持. 因此, 自IIS 7之后, 可以将NetTcpBinding等非HTTP协议的Bindings直接寄宿在IIS上面. 本文将介绍如 ...
- WCF 非http寄宿IIS
摘要 从IIS 7 开始, IIS增加了对非HTTP协议的支持. 因此, 自IIS 7之后, 可以将NetTcpBinding等非HTTP协议的Bindings直接寄宿在IIS上面. 本文将介绍如何在 ...
- 我(webabcd)的文章索引
[最后更新:2014.08.28] 重新想象 Windows Store Apps 系列文章 重新想象 Windows 8 Store Apps 系列文章 重新想象 Windows 8 Store A ...
- WCF 用netTcpbinding,basicHttpBinding 传输大文件
问题:WCF如何传输大文件 方案:主要有几种绑定方式netTcpbinding,basicHttpBinding,wsHttpbinding,设置相关的传输max消息选项,服务端和客户端都要设置,tr ...
- 使用NetTcpBinding,WCF服务未能被激活
我的WCF采用的是NetTcpBinding,使用时就会报错,换成BasicHttpBinding,就一切正常 The requested service, 'net.tcp://wcf.xxxxx. ...
- WCF绑定netTcpBinding寄宿到IIS
继续沿用上一篇随笔中WCF服务类库 Wettery.WcfContract.Services WCF绑定netTcpBinding寄宿到控制台应用程序 服务端 添加WCF服务应用程序 Wettery. ...
- WCF绑定netTcpBinding寄宿到控制台应用程序
契约 新建一个WCF服务类库项目,在其中添加两个WCF服务:GameService,PlayerService 代码如下: [ServiceContract] public interface IGa ...
随机推荐
- 怎么对ORACLE里的CLOB字段进行模糊查询
select b.* from oss_service_log a left join oss_service_log_detail b on a.pk_log = b.pk_log where a. ...
- 【spring源码分析】IOC容器解析
参考: https://www.iteye.com/topic/1121913(自动注入bean的扫描器) https://m.imooc.com/mip/article/34150(循环依赖的解决方 ...
- Spring Boot方式的Dubbo项目
项目依赖 需要org.apache.dubbo.dubbo-dependencies-bom, 需要org.apache.dubbo.dubbo-spring-boot-starter, 当前版本有2 ...
- Laya的Tween缓动没有初始化repeat导致的Bug
当你使用一个Tween给一个图标做旋转动画,循环播放.(repeat是播放次数, repeat=0无限循环,repeat=1播放一次) Laya.Tween.to(this.light,{rotati ...
- 改进初学者的PID-初始化
最近看到了Brett Beauregard发表的有关PID的系列文章,感觉对于理解PID算法很有帮助,于是将系列文章翻译过来!在自我提高的过程中,也希望对同道中人有所帮助.作者Brett Beaure ...
- 【python基础】Python性能加速的方法
参考 1. 给Python加速(性能加速的方法); 2. pythonSpeed_PerformanceTips; 完
- python:单例模式--使用__new__(cls)实现
单例模式:即一个类有且仅有一个实例. 那么通过python怎么实现一个类只能有一个实例呢. class Earth: """ 假如你是神,你可以创造地球 "&q ...
- IDEA下同时使用Git和svn
使用Git时将文件改成Git,Svn时改成svn 修改项目下.idea目录的vcs.xml配置文件. <?xml version="1.0" encoding="U ...
- Python微服务实践-集成Consul配置中心
A litmus test for whether an app has all config correctly factored out of the code is whether the co ...
- 高级UI-画笔Paint
在UI这一块,谈到自定义,就离不开画笔和画布的使用话题,在自定义控件的时候,为了做出炫酷的效果,我们往往会使用画笔和画布,那么这里我们就先来看看画笔的使用吧 简单使用例子 自定义一个View publ ...