服务器和客户端之间的双向通信Two-way Communication between Server and Clients
Situation: We have a web application running on a server. This application needs to fetch data from some other PC(Clients), which are on a different network.
On the clients' pc there are
WCF hosted in
Windows Services using its their local
Sql db. i want to make duplex communication between server and clients for share data with each other.
data share mean share data-table,data-set,string etc between clients and server .
1) I have no control over the firewall, proxy, NAT on the client side PC. Mostly company Employee PCs have lots of network security e.g firewall block ICMP traffic and some port too, some Router might be Disabled port-forwarding etc etc , client can change network place. I don't want to make any setting on client side Router,proxy,firewall though . during communication how can i handle that's kind of issue of client side? as you know skype is working perfect in that situation.
firewalls very often block inbound connections to clients; the client may not be reachable from the server, it may be using NAT translation behind a router and so cannot be contacted without port forwarding being set up on the router and some new router disabled port forwarding .
2) On clients side there is no IIS .
I don't want to allow remote access on clients PC.
There are more than 100 Clients and only one Server. one server need communicate with many clients on different network .
3) One side my client application is using window application and wcf hosted in window service ,Other side on my server i'm using Web application . so its mean communication is between desktop pc and web pc , that's issue .
If both using a web application then it was not issue to make duplex communication.because i know WEBRTC is fit there lol.
Technology which i had already test and find issue
WSDualHttpBinding: Not work if client behind NAT. check this for detail click here
MSMQ : its bad technique if clients more than 1 and performance issue also because its use RAM memory . check here click here
Xsocket: Its also not work if ICMP traffic block by firewall on client. check here click
WebRTC: Its work fine but its support web to web communication .as my client side i have win app.
Socket.io: Its need to set up node.js and many other thing , hard to implement because i need implement on existence application , i am not making new application.
C# Socket Program: Its not work if client and sever on different network .
Service Bus relay: Its not free even for testing .
socketPro: I studied i find its good but i can't find any right sample on google .so that i could test that.
Genuine Channels: I can't find any sample on google .
Lets see SignalR issue .: Server side i run a console application and Client side i run two application ,one is console and other web. when i was running console client application than it was not initiating connection with Server but when i was using web client application then it was working fine. sample link is here SignalR two way communication I can't understand why thas??
Please tell me What is best most secure and fast way to handle this situation? what approach should i use ?
Thanks Advance .
SignalR似乎适合这个解决方案,因为它是灵活的。 的沟通和协商最快可用的通道就是你正在寻找的。 你应该调查的问题和signalR最终将工作。
SignalR seems to fit for this solution, because it's flexible. It negotiates the fastest available channel of communication and that is what you are looking for.
You should investigate the problem with it and signalR will eventually work.
(原文：yes but as i explain above. signalR work if client side web browser application use,,its will not work if use console or win application..)Salvatore Sorbello的回复:SignalR将工作在一个控制台应用程序,看看这里:stackoverflow.com/questions/11140164/…
(原文：SignalR will work in a console application, take a look here: stackoverflow.com/questions/11140164/…)Mike W的回复:尽管SignalR是最流行的web应用程序,它还可以用于控制台或桌面应用程序。检查这个链接例如:code.msdn.microsoft.com/windowsdesktop/…
(原文：Although SignalR is most popular for web applications - it can also be used in console or desktop applications. Check this link for instance: code.msdn.microsoft.com/windowsdesktop/…)Adam的回复:我知道在signalR我可以使用控制台应用程序,但是它唯一的问题在本地主机工作。
(原文：i know in signalR i can use console application but the issue its only work on localhost .)Adam的回复:迈克,你的样品我已经尝试自1月前lol . .在我的例子中,它不工作,我已经解释了,如果我将使用客户端应用程序在客户端然后将自己的工作,如果将使用控制台应用程序,它将没有给任何错误但也不发起连接不了. .
(原文：Mike , your sample i had try since 1 month before lol.. its really not work in my case,, i have explain that if i will use broswer application on client side then its will work ,if will use Console application then its will no give any error but also not initiate connection too..)
I've been working in my spare time with sockets (admittedly in c++, not c# but there shouldn't be a difference), and I've never had an issue connecting to clients behind a firewall/router, even without port forwarding.
Routers and firewalls generally don't like server-like programs, eg. programs that bind the socket to a port number. Does your client do anything related to binding? Because it shouldn't.
Needless to say, I would suggest a socket program. The way I see it, it's the most flexible way.
(原文：socket programming don't work if client and server on different network .its work only if both on LAN network . or both on live IP.you know if client behind Router then its have not a static IP.its IP always change .)xIcarus的回复:
(原文：Only the server needs to have its port forwarded if it's behind a router, or port opened if it's behind a firewall. How else would all our day-to-day applications work? Skype, messengers, even web browsers. Basically, the client connects to the server. After a connection is established, the client chooses to accept the packets. The router has no reason to block the packets since the client specifically requested the information, or that it is waiting for information. And above all, it knows WHERE to redirect the incoming traffic. I'm sorry, what you said is not true.)xIcarus的回复:Ps,从你的其他评论其他答案,你似乎有一个问题与你的网关或类似的东西。我不能看到你的另一个原因发布工作方法。你描述的症状是完全一样:适用于局域网,并# 39;t跨广域网。你100%确定你# 39;正确设置?
(原文：Ps, judging by your other comments on other answers, you seem to have a problem with your gateway or something similar. I cannot see another reason why none of your posted methods worked. The symptoms are exactly as you describe: works in lan, doesn't work across wan. Are you 100% sure you're set up correctly?)Adam的回复:你知道skype工作如何?LOL使用如此多的技术。如果你确定,你想套接字会的工作。然后给我小样本测试。样品像你好发送从客户端pc接收客户机的服务器和服务器响应返回。
(原文：you know skype working how? LOL its using so many technique . any way if you sure and you think socket will work . then just give me small sample for test . sample like hello send from client pc then receive its on server and server response back to that client .)Adam的回复:csharp-examples.net/socket-send-receive。你在说什么? ?
(原文：csharp-examples.net/socket-send-receive . are you talking about its ??)
- 适当的方式加入多个属性对象集合?Proper way to JOIN multiple properties on object collection?
- 试图使用getMethod访问数据和在另一个类中使用它Trying to use a getMethod to access data and use it in another class
- 在Windows 8.1 TcpClient不发送TcpClient not sending on Windows 8.1
- SQL Report Builder 3.0 -在浏览器视图报告PDFSQL Report Builder 3.0 - view Report in browser as PDF
- 服务器和客户端之间的双向通信Two-way Communication between Server and Clients
- 图像重叠在另一个元素使用iTextSharp PDF c#Overlap one image over another image using iTextSharp PDF C#
- 有可能别名长代码行吗?Is it possible to alias a long code line?
- BrowserMob代理-远程服务器返回错误:(404)没有找到BrowserMob Proxy - The remote server returned an error: (404) Not Found
- 如何通过参数从MVC Silverlight吗How to pass parameter from MVC to Silverlight
- 如何添加新节点与treelist数据库吗?how to add new node to database with treelist?