c# - wcf卡在实时服务器上

标签 c# asp.net wcf

我正在开发一个测试项目来实现 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 上都有效

关于c# - wcf卡在实时服务器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30983357/

相关文章:

c# - 我如何创建一个命令行应用程序来强制对某些其他应用程序使用代理?

c# - DataGrid.ColumnWidth ="*"在 ScrollViewer 中不起作用

c# - Linq 返回没有跟进记录的记录

asp.net - Azure Web 应用程序非常慢

c# - 将多个命名空间添加到 MessageContract WCF 响应对象 (MessageBodyMember)

c# - 如何使用 Moq 模拟 HttpRequestMessage

c# - await 在异步操作后不恢复上下文?

asp.net - 如何获取 ASP.NET 服务器应用程序的根目录?

WCF 服务 - 处理行为不端的客户?

c# - 模拟并发 WCF 客户端调用并测量响应时间