Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Create a web service to push messages to clients

Create a web service to push messages to clients

Scheduled Pinned Locked Moved C#
wcflounge
22 Posts 9 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nitin_ion
    wrote on last edited by
    #1

    I want to create a web service for a chat application which will instead of Request/response model use push model. Client app will be notified of a new message, user logged in etc.. by the web service. Does anyone have know where to start any good article with basic knowledge for creating such push web services.

    P M B T realJSOPR 6 Replies Last reply
    0
    • N nitin_ion

      I want to create a web service for a chat application which will instead of Request/response model use push model. Client app will be notified of a new message, user logged in etc.. by the web service. Does anyone have know where to start any good article with basic knowledge for creating such push web services.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      I certainly don't; push is evil and never works. My chat system uses pull. I still haven't yet converted it to use a Web Service. One of the benefits of using pull is that it makes it easier to allow the client to poll at intervals of the user's choosing and to have a "check now" kind of button.

      N 1 Reply Last reply
      0
      • P PIEBALDconsult

        I certainly don't; push is evil and never works. My chat system uses pull. I still haven't yet converted it to use a Web Service. One of the benefits of using pull is that it makes it easier to allow the client to poll at intervals of the user's choosing and to have a "check now" kind of button.

        N Offline
        N Offline
        nitin_ion
        wrote on last edited by
        #3

        Agree to this poll model which is good but now a days client apps needs to be light and with growing numbers of client medium [mobiles, tables etc..] it is much better to let the server push the messages and client to listen. Something similar to push notification of Apple. Do you have any articles on push web service?

        P R 2 Replies Last reply
        0
        • N nitin_ion

          I want to create a web service for a chat application which will instead of Request/response model use push model. Client app will be notified of a new message, user logged in etc.. by the web service. Does anyone have know where to start any good article with basic knowledge for creating such push web services.

          M Offline
          M Offline
          Mehdi Gholam
          wrote on last edited by
          #4

          Web services are inherently request/response. If you really need push you should setup two way communications between your client and server or bring up web services on your clients and send from your server (reversing the process).

          Its the man, not the machine - Chuck Yeager If at first you don't succeed... get a better publicist If the final destination is death, then we should enjoy every second of the journey.

          1 Reply Last reply
          0
          • N nitin_ion

            Agree to this poll model which is good but now a days client apps needs to be light and with growing numbers of client medium [mobiles, tables etc..] it is much better to let the server push the messages and client to listen. Something similar to push notification of Apple. Do you have any articles on push web service?

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            nitin_ion wrote:

            it is much better to let the server push the messages and client to listen

            No it's not. Trust me on this - I spent a lot of time working on a push application back in the late 90s, and the problems that had to be overcome are immense. With a push mechanism, you have to keep track of connected clients and track of what you have sent to the client. Suppose that you get a temporary network outage to a client and you push a message out, you need to track this and take some action based on this - for instance, you may allow a retry interval and then attempt to push the message again. Remember that connections are finite resources, so you'd have to create a disconnected push mechanism which is a whole magnitude of complexity beyond. There are all sorts of tricks that you have to employ there.

            Forgive your enemies - it messes with their heads

            My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

            N 1 Reply Last reply
            0
            • P Pete OHanlon

              nitin_ion wrote:

              it is much better to let the server push the messages and client to listen

              No it's not. Trust me on this - I spent a lot of time working on a push application back in the late 90s, and the problems that had to be overcome are immense. With a push mechanism, you have to keep track of connected clients and track of what you have sent to the client. Suppose that you get a temporary network outage to a client and you push a message out, you need to track this and take some action based on this - for instance, you may allow a retry interval and then attempt to push the message again. Remember that connections are finite resources, so you'd have to create a disconnected push mechanism which is a whole magnitude of complexity beyond. There are all sorts of tricks that you have to employ there.

              Forgive your enemies - it messes with their heads

              My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

              N Offline
              N Offline
              nitin_ion
              wrote on last edited by
              #6

              Yes for most of the issue pull is better but there are some areas where push is better. like ads, alerts etc.

              P 1 Reply Last reply
              0
              • N nitin_ion

                Yes for most of the issue pull is better but there are some areas where push is better. like ads, alerts etc.

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                If you look at ad services (such as the one's here on CP), you'll find that the majority are based around pull mechanisms. Similarly, alerts are generally polled on web based systems.

                Forgive your enemies - it messes with their heads

                My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                1 Reply Last reply
                0
                • N nitin_ion

                  I want to create a web service for a chat application which will instead of Request/response model use push model. Client app will be notified of a new message, user logged in etc.. by the web service. Does anyone have know where to start any good article with basic knowledge for creating such push web services.

                  B Offline
                  B Offline
                  BobJanova
                  wrote on last edited by
                  #8

                  It can't be done; as Mehdi says, web services are implemented on top of HTTP and are inherently request/response (i.e. pull) oriented. Either you can do it with polling (some sort of intelligent polling that alters its frequency based on activity, if you want to be friendly to your server), or you can come away from the web service idea altogether and create a client/server connection based (probably TCP) chat application. There is simply no such thing as a push model web service due to the protocol on which web services are defined. However, on any thin client (whether in browser or not) to a web service, you are sending quite a lot of requests anyway, onto which you can piggyback update notification information without adding extra server load. For example, imagining an online IRC type application, you are sending a request every time you type a message, change your status, look up information on another user, join or leave a room, as well as obvious things like following links. The trick is to include update notification (for chat messages, PMs, users in a room, etc) as part of every service response, if you want to minimise requests and still get frequent updates.

                  N 2 Replies Last reply
                  0
                  • B BobJanova

                    It can't be done; as Mehdi says, web services are implemented on top of HTTP and are inherently request/response (i.e. pull) oriented. Either you can do it with polling (some sort of intelligent polling that alters its frequency based on activity, if you want to be friendly to your server), or you can come away from the web service idea altogether and create a client/server connection based (probably TCP) chat application. There is simply no such thing as a push model web service due to the protocol on which web services are defined. However, on any thin client (whether in browser or not) to a web service, you are sending quite a lot of requests anyway, onto which you can piggyback update notification information without adding extra server load. For example, imagining an online IRC type application, you are sending a request every time you type a message, change your status, look up information on another user, join or leave a room, as well as obvious things like following links. The trick is to include update notification (for chat messages, PMs, users in a room, etc) as part of every service response, if you want to minimise requests and still get frequent updates.

                    N Offline
                    N Offline
                    nitin_ion
                    wrote on last edited by
                    #9

                    ok, but then how does push notification services work. aren't they web services?

                    P P 2 Replies Last reply
                    0
                    • N nitin_ion

                      ok, but then how does push notification services work. aren't they web services?

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #10

                      Nope.

                      Forgive your enemies - it messes with their heads

                      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                      N 1 Reply Last reply
                      0
                      • P Pete OHanlon

                        Nope.

                        Forgive your enemies - it messes with their heads

                        My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                        N Offline
                        N Offline
                        nitin_ion
                        wrote on last edited by
                        #11

                        can callback functions be used to see if a user sends message using request/response to webservice then web service should push that message to that user. something which is google doing if we see in other messengers they do it using traditionally req/res but google , skype are using push for their messages.

                        B 1 Reply Last reply
                        0
                        • N nitin_ion

                          ok, but then how does push notification services work. aren't they web services?

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #12

                          nitin_ion wrote:

                          how does push notification services work

                          They don't, they never have, it's a very bad idea. Just implement pull and allow the user to determine the frequency he likes.

                          1 Reply Last reply
                          0
                          • B BobJanova

                            It can't be done; as Mehdi says, web services are implemented on top of HTTP and are inherently request/response (i.e. pull) oriented. Either you can do it with polling (some sort of intelligent polling that alters its frequency based on activity, if you want to be friendly to your server), or you can come away from the web service idea altogether and create a client/server connection based (probably TCP) chat application. There is simply no such thing as a push model web service due to the protocol on which web services are defined. However, on any thin client (whether in browser or not) to a web service, you are sending quite a lot of requests anyway, onto which you can piggyback update notification information without adding extra server load. For example, imagining an online IRC type application, you are sending a request every time you type a message, change your status, look up information on another user, join or leave a room, as well as obvious things like following links. The trick is to include update notification (for chat messages, PMs, users in a room, etc) as part of every service response, if you want to minimise requests and still get frequent updates.

                            N Offline
                            N Offline
                            nitin_ion
                            wrote on last edited by
                            #13

                            like you said polling there is also other mechanism like using comet with wcf and using callbacks. do you have any articles on polling, comet or callbacks which gives knowledge on how to use it in wcf

                            B P 2 Replies Last reply
                            0
                            • N nitin_ion

                              can callback functions be used to see if a user sends message using request/response to webservice then web service should push that message to that user. something which is google doing if we see in other messengers they do it using traditionally req/res but google , skype are using push for their messages.

                              B Offline
                              B Offline
                              BobJanova
                              wrote on last edited by
                              #14

                              Skype opens and maintains a persistent TCP connection to a server. Google: I guess you are talking about the standalone app? The in-browser chat uses AJAX and polling. I think their standalone app opens a persistent TCP connection but it might be using client side polling, I'm not sure. I don't really understand your first sentence in this post. You can use a callback to see when a particular request to the service returns, if you fire the request asynchronously. Is that what you mean? (Synchronous WCF client calls actually wrap this asynchronous approach and use a wait handle to wait for a response, if I remember right.) That doesn't change what is going on underneath or the fact that a request must be initiated by the client, though.

                              1 Reply Last reply
                              0
                              • N nitin_ion

                                like you said polling there is also other mechanism like using comet with wcf and using callbacks. do you have any articles on polling, comet or callbacks which gives knowledge on how to use it in wcf

                                B Offline
                                B Offline
                                BobJanova
                                wrote on last edited by
                                #15

                                Polling is trivial (a client side timer or other mechanism that repeatedly makes a request to the service asking about updates). The comet method I haven't heard of before, but it seems to be an abuse of the TCP timeout mechanism whereby you stall a request until there is an update. I'm not sure there is a way to do that with a WCF service without going in at the low level. This form of polling is bad though (for the reason that persistent connections are: while that request is open, it counts against your machine socket resources, concurrent connections etc which are generally more precious than bandwidth), except for very specific cases where you know there will be an update soon (within a second or so). You can use callbacks in a WCF client to respond to a service request asynchronously (i.e. you fire it off, continue processing and respond to the request you initiated later). This would typically be used as part of polling, as you don't want to stall client interaction while you want for a response. Honestly, for a chat application, you are better off either using persistent connections (think IRC) for an update-critical standalone app, or using simple HTTP with client side polling (either through AJAX or thick client code doing a similar thing) for a less update-critical one or a web (in browser) chat. This is not what web services are for and they will get in the way rather than helping you.

                                1 Reply Last reply
                                0
                                • N nitin_ion

                                  like you said polling there is also other mechanism like using comet with wcf and using callbacks. do you have any articles on polling, comet or callbacks which gives knowledge on how to use it in wcf

                                  P Offline
                                  P Offline
                                  Pete OHanlon
                                  wrote on last edited by
                                  #16

                                  nitin_ion wrote:

                                  do you have any articles on polling, comet or callbacks which gives knowledge on how to use it in wcf

                                  You have already been given an answer to this. Your post here is just plain rude.

                                  Forgive your enemies - it messes with their heads

                                  My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                                  1 Reply Last reply
                                  0
                                  • N nitin_ion

                                    I want to create a web service for a chat application which will instead of Request/response model use push model. Client app will be notified of a new message, user logged in etc.. by the web service. Does anyone have know where to start any good article with basic knowledge for creating such push web services.

                                    T Offline
                                    T Offline
                                    Tony Pazzard
                                    wrote on last edited by
                                    #17

                                    Have a look at this: WCF / WPF Chat Application[^]

                                    1 Reply Last reply
                                    0
                                    • N nitin_ion

                                      Agree to this poll model which is good but now a days client apps needs to be light and with growing numbers of client medium [mobiles, tables etc..] it is much better to let the server push the messages and client to listen. Something similar to push notification of Apple. Do you have any articles on push web service?

                                      R Offline
                                      R Offline
                                      Roger Wright
                                      wrote on last edited by
                                      #18

                                      There is nothing good about the push model, period. Users will despise you, and waste tons of money on tech support to remove your nasty, intrusive application from their machines. People will revile you, and spit on your avatar in FarmTown, even at the expense of having to wipe their screens once in a while with a damp cloth. You will be a pariah in the realm of software development, and will never be invited to the really good hospitality suites hosted by top vendors at developer conferences, the ones where the booze and food are free, and served by scantily clad booth bimbos they rent by the hour from the local brothels. I, for one, refuse to buy any Adobe product because of their constant update notifications for their ubiquitous Reader product, and I despise Microsoft for their intrusive approach to installing inadequately tested patches that destroy perfectly functional machines, overnight. A pox on whoever conceived the notion of push products; may the fleas of a thousand camels infest his armpits, and may all the crabs in Las Vegas take up residence in his crotch. Just don't...

                                      Will Rogers never met me.

                                      1 Reply Last reply
                                      0
                                      • N nitin_ion

                                        I want to create a web service for a chat application which will instead of Request/response model use push model. Client app will be notified of a new message, user logged in etc.. by the web service. Does anyone have know where to start any good article with basic knowledge for creating such push web services.

                                        realJSOPR Offline
                                        realJSOPR Offline
                                        realJSOP
                                        wrote on last edited by
                                        #19

                                        Web services don't technically push. They're based on a request/serve paradigm, meaning you have to connect, call a method, and accept the output.

                                        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                        -----
                                        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                        -----
                                        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                                        N 1 Reply Last reply
                                        0
                                        • realJSOPR realJSOP

                                          Web services don't technically push. They're based on a request/serve paradigm, meaning you have to connect, call a method, and accept the output.

                                          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                          -----
                                          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                          -----
                                          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                                          N Offline
                                          N Offline
                                          nitin_ion
                                          wrote on last edited by
                                          #20

                                          Thanks, this is correct. I just looked at some articles and accordingly if we use basichttpbinding we cannot create duplex service but with wshttpbinding we can. but with it then we need to make sure that ports, firewall issues are taken care of on client machine. I am not sure but there should be some way using using basichttpbinding by which i can create callback methods.

                                          realJSOPR 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups