3

I have a server/client project, I am using C# for coding, WCF as server. I am limited to HTTP, had no luck with wsdualhttpbinding so far. Project is working on company network.

Is there any way to send notifications from server to client in any way other than WCF duplex? Please tell all options.

  • "Is there any way to send notifications from server to client in any way other than WCF duplex" - Why has that option been ruled out? – vcsjones Nov 14 '11 at 02:45
  • so many problems on production stage when u put things in real servers.. i just got headache from it.. and if it worked with one client.. that does not mean it will work with the other.. plus, when u use wsdualhttpbinding simply you are making the server side as client in addition to its job as server, and you are making your client as a server in addition to being client.. ports issues... just can't handle that... its a failure.. –  Nov 14 '11 at 02:49
  • Maybe you should ask questions about your use of duplex. Most other people don't have problems with it. – John Saunders Nov 14 '11 at 02:51
  • please be my guest: http://stackoverflow.com/questions/8116554/wcf-wsdualhttpbinding-strange-behaviour-at-client-side-that-has-no-clear-except –  Nov 14 '11 at 03:12

2 Answers2

2

I am assuming because of firewall issues you have problems with an incoming connection.

In such a scenario a common way to solve the problem is.

  1. Have a separate thread from which you poll the server using the service request A maybe GetNextNotification
  2. This connection should have a high timeout.
  3. On the server side when A is processed the method doesn't return until there is something server wants to convey to the client
  4. Once A returns the client processes the notification and makes another A request.
parapura rajkumar
  • 24,045
  • 1
  • 55
  • 85
  • Its a smart idea, i might give it a try. btw, do u mean like using a background worker...? what about the impact on the service,, specially if more than 40 clients are connected at the same time to the service... any idea? –  Nov 14 '11 at 02:46
  • I made it just like you suggested, and things are working so fine.. u r a life saver.. thanks –  Nov 14 '11 at 20:23
  • @HalaBi...Can't you have a singleton instancecontextmode for the notification service... so it should work in theory – parapura rajkumar Nov 15 '11 at 11:58
  • can you give me more details plz –  Nov 15 '11 at 12:45
  • The general idea is on your service contract you set InstanceContextMode.Single so all notification requests go to the same service. Also set ConcurrencyMode to Multiple to support multiple requests simultaneously. Now all GetNextNotification requests can wait for a single event which you can manage and fire when a new notification needs to be sent to all clients – parapura rajkumar Nov 15 '11 at 13:20
  • Good Idea, Actually this is how i wanted to do it... but then i thought i would need to manage the singleton pattern and locks and blah blah. and then if an exception thrown all will stop.. so i just made it simple.. all services will send the notifications to a database table.. the notification service will loop and check the table every 2500ms.. if something new in the table it will return it.. if nothing it will keep looping.. hope this will not be a problem.. ur advice is appreciated. –  Nov 15 '11 at 13:55
  • Also google for **wcf long polling** you will get lot of resources – parapura rajkumar Nov 15 '11 at 13:59
0

There is solution currently being build over ASP.Net called SignalR. Have a look. I think it uses long polling to achieve the results

Chandermani
  • 42,589
  • 12
  • 85
  • 88