none
Unsolicited messages from a web service to a client? RRS feed

  • Question

  • I'm in the process of deciding how best to design an application that has a central server that will control the actions of multiple clients. I was thinking of using a web application of some sort to act as the server. The clients will register themselves with the server and the server will post unsolicited messages to the clients as needed. The question is, what would be the best way to do this? A web server normally responds to requests from a client. In this case the server will need to pop off unsolicited messages as needed. Is this possible and, if so, how?

    Richard Lewis Haggard

    Friday, November 23, 2018 10:18 PM

Answers

  • Yes, a web server can never initiate a transaction to a client. 

    A ASP.NET SignalR Web application running on a Web server can do it.

    https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/tutorial-server-broadcast-with-signalr

    <copied>

    This tutorial shows how to create a web application that uses ASP.NET SignalR 2 to provide server broadcast functionality. Server broadcast means that communications sent to clients are initiated by the server. This scenario requires a different programming approach than peer-to-peer scenarios such as chat applications, in which communications sent to clients are initiated by one or more of the clients.

    <end>

    Wednesday, November 28, 2018 12:03 AM

All replies

  • Hi Richard.Haggard,

    As far as I know, WCF and web API does not have API to popup related windows to show unsolicited messages, I would suggest that you could write polling windows application, such as WPF, Winforms to popup your unsolicited messages via polling.

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 26, 2018 3:02 AM
    Moderator
  • Hi Richard.Haggard,

    As far as I know, WCF and web API does not have API to popup related windows to show unsolicited messages, I would suggest that you could write polling windows application, such as WPF, Winforms to popup your unsolicited messages via polling.

    Best regards,

    Zhanglong


    Zhanglong, I believe that you misinterpreted what Richard meant when he said "the server will need to pop off unsolicited messages as needed". He meant "pop the unsolicited messages off of" a queue of some sort, and send the messages to the appropriate client. He did *not* mean "pop up" a window on the server.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Monday, November 26, 2018 5:54 AM
    Moderator
  • Hi,

    Sorry for my mistake, maybe the following document about Queues in Windows Communication Foundation will be helpful to you.

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/queues-in-wcf

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 26, 2018 6:04 AM
    Moderator
  • WCF is limited now in its usage with WebAPI and SignalR now starting to supplant it due to a broader range of client devices can consume WebAPI solutions easily using Json as opposed to SOAP and WCF Web service.    
    Monday, November 26, 2018 7:37 AM
  • Yes, a web server can never initiate a transaction to a client.  There are really two alternatives: either use a more general TCP socket, rather than HTTP, or else have the clients periodically poll for any unsent traffic.  This is how single-page web sites do it; they have a one-per-second timer that sends an AJAX request to the server, and use the results to update their visible state.

    Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

    Tuesday, November 27, 2018 10:40 PM
  • Yes, a web server can never initiate a transaction to a client. 

    A ASP.NET SignalR Web application running on a Web server can do it.

    https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/tutorial-server-broadcast-with-signalr

    <copied>

    This tutorial shows how to create a web application that uses ASP.NET SignalR 2 to provide server broadcast functionality. Server broadcast means that communications sent to clients are initiated by the server. This scenario requires a different programming approach than peer-to-peer scenarios such as chat applications, in which communications sent to clients are initiated by one or more of the clients.

    <end>

    Wednesday, November 28, 2018 12:03 AM
  • I'll need to spend some time working through this but it looks promising. Thanks for the pointer.

    Richard Lewis Haggard

    Wednesday, November 28, 2018 1:12 AM