3

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 .

Problem :

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 wouldn't work if client behind NAT.check here click for detail

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 ?

Community
  • 1
  • 1
Adam
  • 173
  • 2
  • 14

3 Answers3

5

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.

Mohamad Shiralizadeh
  • 8,329
  • 6
  • 58
  • 93
Mike W
  • 308
  • 3
  • 5
  • 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.. – Adam Jan 05 '15 at 12:53
  • 1
    SignalR will work in a console application, take a look here: http://stackoverflow.com/questions/11140164/signalr-console-app-example – Salvatore Sorbello Jan 05 '15 at 12:59
  • Although SignalR is most popular for web applications - it can also be used in console or desktop applications. Check this link for instance: https://code.msdn.microsoft.com/windowsdesktop/Using-SignalR-in-WinForms-f1ec847b – Mike W Jan 05 '15 at 13:00
  • 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.. – Adam Jan 05 '15 at 13:09
  • Mike . I've post my question after lot of test . – Adam Jan 05 '15 at 13:13
  • So I can only advise you to test more, try to isolate the problem, by removing from the test everything but the core signalR functionality. – Mike W Jan 05 '15 at 16:46
  • I'm using SignalR extensively to communicate between the servers (C#), between server and mobile apps (C#, Xamarin, iOS, Android). The servers are at different locations and the mobile apps can be anywhere. It all works very reliable. Take a look at: http://www.asp.net/signalr/overview/deployment/tutorial-signalr-self-host and here http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-net-client – Arthur Kater Aug 29 '15 at 11:14
2

I'm using SignalR extensively to communicate between the servers (C#), between server and mobile apps (C#, Xamarin, iOS, Android). The servers are at different locations and the mobile apps can be anywhere. It all works very reliable.

Take a look at: http://www.asp.net/signalr/overview/deployment/tutorial-signalr-self-host and here http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-net-client

Arthur Kater
  • 826
  • 10
  • 17
0

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.

xIcarus
  • 371
  • 7
  • 15
  • 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 . – Adam Jan 05 '15 at 12:51
  • 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 Jan 05 '15 at 13:51
  • 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? – xIcarus Jan 05 '15 at 13:54
  • 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 Jan 05 '15 at 13:56
  • http://www.csharp-examples.net/socket-send-receive/ . are you talking about its ?? – Adam Jan 05 '15 at 13:57
  • well just bear in mind about client side issue. take a look. Internet ==>> Router NAT ==>> Fire Wall ==>> Proxy==>> Client PC . you can image now where is client PC . and how its will pass through Firewall,Proxy ,NAt . how sever will detect Client IP . as you know client can't Ping google also but can access if firewall block ICMP traffice. – Adam Jan 05 '15 at 14:01
  • Wait wait. My friend, first you said that sockets won't work on different networks. Now you said that it won't work if the firewall blocks ICMP traffic. Those are 2 completely different situations. That doesn't mean sockets won't work on different networks. I strongly suggest you should update your initial question with this aspect. Nonetheless, check out this example and try it: http://www.codeproject.com/Articles/463947/Working-with-Sockets-in-Csharp This is what I used when I started learning sockets in c#. It worked for me, it should work for you. – xIcarus Jan 06 '15 at 08:33
  • @xclarus .My friend you really no get me. look this link . http://stackoverflow.com/questions/15280201/connect-an-ip-behind-nat-using-sockets – Adam Jan 06 '15 at 09:29