首页 新闻 赞助 找找看

wcf 双工通信 服务端部署到服务器(外网)后,本地客户端能添加引用,但通道连接时超时

0
悬赏园豆:20 [待解决问题]
服务端在本地时,客户端能添加引用,通道也能连接上,但将服务端放在服务器后,我在本地vs2013上添加对应的服务引用能成功,通道在打开时连接超时,
宿主是寄宿在控制台应用程序上的,客户端是winform程序
客户端代码:
MessagePushCallBack callBack = new MessagePushCallBack();
InstanceContext context = new InstanceContext(callBack);
ServiceReference_MessagePush.MessagePushServiceClient client = new ServiceReference_MessagePush.MessagePushServiceClient(context);
client.Open();

client.Open();-----这个地方会报错:打开操作没有在分配的超时 00:00:19.6849819 内完成。分配给此操作的时间可能已经是更长超时的一部分。
路由器端口已经映射,服务器防火墙出站入站都添加了

服务端配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="abc">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://171.221.241.17:8006/MessagePushService/metadata" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <services>
      <service name="FineEx.JQSM.Back.MessagePushService" behaviorConfiguration="abc">
        <endpoint address="" binding="wsDualHttpBinding" contract="FineEx.JQSM.Back.IMessagePushService" bindingConfiguration="wsdualbinding" >
          <identity>
            <dns value="171.221.241.17" />
          </identity>
        </endpoint>

        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://171.221.241.17:8006/MessagePushService/" />
            <add baseAddress="net.tcp://171.221.241.17:8006/MessagePushService"/>
          </baseAddresses>
        </host>
      </service>
    </services>

    <bindings>
      <wsDualHttpBinding>
        <binding name="wsdualbinding"
                 closeTimeout="00:00:30"
                 maxReceivedMessageSize="500000"
                 maxBufferPoolSize="50000"
                 sendTimeout="00:01:00"
                 openTimeout="00:00:20"
                 receiveTimeout="00:00:30">
          <reliableSession ordered="true" inactivityTimeout="00:00:30" />
          <security mode="None">
            <message clientCredentialType="None"/>
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

客户端配置自动生成的

Medusa Gorgon的主页 Medusa Gorgon | 初学一级 | 园豆:182
提问于:2015-08-21 11:25
< >
分享
所有回答(1)
0

wsDualHttpBinding 绑定需要通信双方在各自的 IP 和端口上监听。根据你的描述,你的服务端有公网 IP ,但是你的客户端没有公网 IP ,因此服务端无法建立到客户端的连接。

Launcher | 园豆:45045 (高人七级) | 2015-08-21 11:34

谢谢你的回答,这个端口监听怎么做,是在配置文件还是别的地方,有没有参考文章推荐一下,

支持(0) 反对(0) Medusa Gorgon | 园豆:182 (初学一级) | 2015-08-21 14:09

@Medusa Gorgon: 虽然我说的,跟你说的是两回事,但是我还是帮你随便搜了一篇文章:http://www.cnblogs.com/danielWise/archive/2010/11/25/1887358.html,你不用谢我,我使用搜索引擎的能力比你强。

支持(0) 反对(0) Launcher | 园豆:45045 (高人七级) | 2015-08-21 15:00

@Launcher: 使用搜索引擎的能力比你强

这点我承认,关键词找不好,搜索结果大相径庭

支持(0) 反对(0) Medusa Gorgon | 园豆:182 (初学一级) | 2015-08-21 15:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册