WCF中的双向通信MSMQ可以处理客户端的防火墙问题吗? [英] In Two Way communication MSMQ in WCF can handle Firewall issue of Client side?

查看:21
本文介绍了WCF中的双向通信MSMQ可以处理客户端的防火墙问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划使用 MSMQ 进行客户端和服务器之间的双向通信.客户端将是托管在 Window 服务中的 WCF,并通过 Internet 与服务器通信.显然我无法控制客户端的防火墙、代理、NAT,

I'm planning on using a MSMQ for two way communication between Client and server. The clients will be a WCF hosted in Window services and communicating to the server over the internet. Obviously I have no control over the firewall,proxy,NAT on the client side,

所以我想知道设置 MSMQ netMsmqBinding 的正确方法是什么?

so I'm wondering what is the proper way to set MSMQ netMsmqBinding ?

现在在我的初始测试中,我在同一台电脑上运行服务器和客户端,我正在设置绑定如下

Right now in my intiial testing I'm running the server and client on the same pc and i am setting the binding as follows

    <!--Address attribute specifies the name of the MSMQ Queue.-->
    <endpoint name="msmqTransactionEndpoint" address="net.msmq://localhost/UpdateEmpTwoWay/UpdateEmp" binding="netMsmqBinding"
                      bindingConfiguration="myMSMQ" contract="EmployeeUpdateReportComponent.IEmployee"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="net.msmq://localhost/private/"/>
        <!--Both Mex and HttpBinding uses http://localhost:8888 port-->
        <add baseAddress="http://localhost:57829"/>
      </baseAddresses>
    </host>
  </service>

但是我感觉这在通过 Internet 部署时不起作用,因为localhost"不会转换为机器地址(更不用担心 NAT 转换)并且该端口、ICMP 流量可能会被客户端阻止防火墙.

But I have a feeling this won't work when deploying over the internet because "localhost" won't translate to the machine address (much less worrying about NAT translation) and that port,ICMP traffic might be blocked by the clients firewall .

处理这个问题的正确方法是什么?我在那里看到了公共和私人队列,我们​​必须设置它们.但我不知道我是否在服务器上为消息队列设置了公共队列,然后它会起作用与否.

What is the proper way to handle this issue ? I saw there Public and private queues ,which we have to setup .but i've not idea if i set public queues on server for Message Queuing then its will work or not .

所以告诉我什么时候运行 win form wcf 客户端应用程序,然后我如何打开我的自定义端口,比如6667",并指导我应该使用什么库或什么方法作为结果响应应该来自客户端路由器到电脑和防火墙不会阻止任何东西.请结合现实生活场景讨论这个问题,人们在现实生活中如何处理这种情况.

so just tell me when win form wcf client apps will run then how can i open my custom port like "6667" and also guide me what library or what approach i should use as a result response should come from client side router to pc and firewall will not block anything. please discuss this issue with real life scenario how people handle this kind of situation in real life.

注意:如果您对服务器和客户端之间的双向通信有任何其他想法,也请告诉我

Note : if you've any other idea for two way communication between server and client ,let me know its too

谢谢

推荐答案

MSMQ 用于单向通信.一个进程将项目发送到队列,另一个进程读取它们.

MSMQ is for one way communication. One process sends items to the Queue and another reads them.

您可以通过使用两个队列来解决这个问题,一个是客户端写入服务器读取,另一个是服务器写入和客户端读取.但是当有多个客户端时就会出现问题,但是有一些方法可以解决这个问题,例如每个客户端一个队列.

You could solve it by having two Queues, one that the Client Writes to and the server reads, and another that the server Writes to and the Client reads. But then there are problems when there is more than one Client, but there are ways around that, for example a Queue per Client.

我认为更好的解决方案是使用为 2 路通信而构建的 SignalR 之类的东西,请查看:http://www.asp.net/signalr

I think that a better solution would be to use something like SignalR that is built for 2 way communication, have a look at: http://www.asp.net/signalr

这篇关于WCF中的双向通信MSMQ可以处理客户端的防火墙问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆