wcf挂在实时服务器上
wcf hanging on live server
我正在开发一个实现 wcf 回调的测试项目,当我在本地调试时,我的代码可以正常工作,然后回调实际上可以正常工作,但是当我连接到实时服务器时,它会简单地冻结任何方法。
我尝试了所有的Conncurency模式,我尝试设置超时但都失败了
public interface IWorkplaySupportServiceCallBack
{
[OperationContract(IsOneWay = true)]
void HandleData(byte[] buffer);
[OperationContract(IsOneWay = true)]
void SessionCreated();
}
[ServiceContract(CallbackContract = typeof(IWorkplaySupportServiceCallBack))]
public interface IWorkplaySupportService
{
[OperationContract(IsOneWay = true)]
void CreateSession(string sessionId);
}
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant, UseSynchronizationContext = false)]
public class WorkplaySupportService : IWorkplaySupportService
{
public void CreateSession(string sessionId)
{
var callback = OperationContext.Current.GetCallbackChannel<IWorkplaySupportServiceCallBack>();
callback.SessionCreated();
}
}
这是我的配置
<!-- WCF START-->
<bindings>
<wsDualHttpBinding>
<binding name="basicHttpFor2MBMessage" maxBufferPoolSize="2097152"
maxReceivedMessageSize="2097152" messageEncoding="Mtom">
<readerQuotas maxArrayLength="2097000" />
<security mode="None">
<message clientCredentialType="None" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="wsDualHttpBinding.SampleServiceBehavior"
name="Workflowms.Web.webservices.support.WorkplaySupportService">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="basicHttpFor2MBMessage"
contract="Workflowms.Web.webservices.support.IWorkplaySupportService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wsDualHttpBinding.SampleServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
通过使用 Trace 事件,我弄清楚了为什么它没有响应,但我不知道如何解决这个问题,连接的客户端是我的笔记本电脑,而服务器不在同一网络上(通过 Internet 连接) ,我在 Internet 上添加了 wcf 引用,但是当我 运行 它没有连接时,在服务器跟踪事件上我得到以下异常
在 http://donald-pc/Temporary_Listen_Addresses/f9dbbcde-f968-48f1-bc48-e1e12dd13e32/6ca1305c-95e4-4248-a5f3-cbb594ea8a26 处没有侦听可以接受消息的端点。这通常是由不正确的地址或 SOAP 操作引起的。有关详细信息,请参阅 InnerException(如果存在)。
我通过更改
设法使其正常工作
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="basicHttpFor2MBMessage" contract="Workflowms.Web.webservices.support.IWorkplaySupportService"> </endpoint>
到
<endpoint address="" binding="netHttpBinding" bindingConfiguration="netHttpBinding" contract="Workflowms.Web.webservices.support.IWorkplaySupportService">
并添加
<netHttpBinding>
<binding name="netHttpBinding" maxBufferPoolSize="2097152"
maxReceivedMessageSize="2097152" messageEncoding="Mtom">
<readerQuotas maxArrayLength="2097000" />
<security mode="None">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</netHttpBinding>
现在我的回调在 Intranet 和 Internet 上都有效
我正在开发一个实现 wcf 回调的测试项目,当我在本地调试时,我的代码可以正常工作,然后回调实际上可以正常工作,但是当我连接到实时服务器时,它会简单地冻结任何方法。
我尝试了所有的Conncurency模式,我尝试设置超时但都失败了
public interface IWorkplaySupportServiceCallBack
{
[OperationContract(IsOneWay = true)]
void HandleData(byte[] buffer);
[OperationContract(IsOneWay = true)]
void SessionCreated();
}
[ServiceContract(CallbackContract = typeof(IWorkplaySupportServiceCallBack))]
public interface IWorkplaySupportService
{
[OperationContract(IsOneWay = true)]
void CreateSession(string sessionId);
}
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant, UseSynchronizationContext = false)]
public class WorkplaySupportService : IWorkplaySupportService
{
public void CreateSession(string sessionId)
{
var callback = OperationContext.Current.GetCallbackChannel<IWorkplaySupportServiceCallBack>();
callback.SessionCreated();
}
}
这是我的配置
<!-- WCF START-->
<bindings>
<wsDualHttpBinding>
<binding name="basicHttpFor2MBMessage" maxBufferPoolSize="2097152"
maxReceivedMessageSize="2097152" messageEncoding="Mtom">
<readerQuotas maxArrayLength="2097000" />
<security mode="None">
<message clientCredentialType="None" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="wsDualHttpBinding.SampleServiceBehavior"
name="Workflowms.Web.webservices.support.WorkplaySupportService">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="basicHttpFor2MBMessage"
contract="Workflowms.Web.webservices.support.IWorkplaySupportService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wsDualHttpBinding.SampleServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
通过使用 Trace 事件,我弄清楚了为什么它没有响应,但我不知道如何解决这个问题,连接的客户端是我的笔记本电脑,而服务器不在同一网络上(通过 Internet 连接) ,我在 Internet 上添加了 wcf 引用,但是当我 运行 它没有连接时,在服务器跟踪事件上我得到以下异常 在 http://donald-pc/Temporary_Listen_Addresses/f9dbbcde-f968-48f1-bc48-e1e12dd13e32/6ca1305c-95e4-4248-a5f3-cbb594ea8a26 处没有侦听可以接受消息的端点。这通常是由不正确的地址或 SOAP 操作引起的。有关详细信息,请参阅 InnerException(如果存在)。
我通过更改
设法使其正常工作<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="basicHttpFor2MBMessage" contract="Workflowms.Web.webservices.support.IWorkplaySupportService"> </endpoint>
到
<endpoint address="" binding="netHttpBinding" bindingConfiguration="netHttpBinding" contract="Workflowms.Web.webservices.support.IWorkplaySupportService">
并添加
<netHttpBinding>
<binding name="netHttpBinding" maxBufferPoolSize="2097152"
maxReceivedMessageSize="2097152" messageEncoding="Mtom">
<readerQuotas maxArrayLength="2097000" />
<security mode="None">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</netHttpBinding>
现在我的回调在 Intranet 和 Internet 上都有效