I would like to program a software that will heavily utilize client side development (JavaScript), and I want to communicate with the server. Is there a way similar to SignalR where I can keep communicating with the server to get new updates if any?

Something similar to LinkedIn where when there is a new update, it will show you that there is 1 or 2 updates available, so you can click to see them.

I know I can use setTimeOut and keep checking with the server, but is it the right way?


Okay, first things first. SignalR is not a server-side-only technology. It also lives on the client. That's its selling point. It abstracts the heavy lifting of damn-near-real-time communication between client and server. Wasn't sure if that was clear given the question title.

With that out of the way, if you're interested in how SignalR works, then yes, one of its approaches is to send an occasional request to the server to see if anything's changed. That's called ajax long polling. It's not SignalR's first strategy because, well, it kinda stinks. Just think of all the things that could go wrong. Not to mention it's not a real-time two-way update since the server can't initiate a change. SignalR prefers to use Websockets if they're available.

They call it a fallback strategy. SignalR tries an HTML5 technology like WebSockets. If that's not available, it falls back to one of the old Comet tricks. Pretty smart, really.

SignalR is definitely not the only game in town. Other options span from cool projects like Meteor (Meteor is a lot more than real-time client/server communication, it's pretty huge) to more focused projects like socket.io. Keep in mind that since bidirectional communication requires both a client and server, each project uses different server technology. Since you mention SignalR, I'm going to guess you're using (or are considering) a Microsoft technology. In that case, you have fewer options.

If what you're really asking is how to implement bespoke bidirectional client/server communication, then start with WebSockets (tutorial). If you have many users, you'll probably find that some of them are using older tech that doesn't support WebSockets (or maybe you're using older server tech that doesn't support it). In that case, take a look at Comet (tutorial). By the time you get all of that done (or imagine the time it would take), SignalR might look better to you.

  • Thanks for your answer. I don't have access to the server. Its' cloud solution (Office 365) where you only have access to the site itself. Would SignalR work in that way? Do I need to deploy some stuff for the server for it to work? I think it needs to deploy some stuff on the server that's why I am looking for something client side only. Can you clarify please? Thanks – Natalie Jan 1 '16 at 11:27
  • @Natalie If you're asking how to do bidirectional communication with a server you don't control, the answer is probably "you're stuck with whatever the server supports", which might be nothing. If you don't know what they provide, that's a support question only they can answer. – Ixrec Jan 1 '16 at 15:09
  • @Natalie Sounds like you're out of luck. SignalR requires that you control both client and server. You'll have to poll for changes for now. From what I understand, Office 365 APIs are strictly pull versus push today. – Scant Roger Jan 1 '16 at 17:55
  • agree with you about question title, it doesn't feel okay. Guess it is title that caused so many downvotes and even an incorrect vote to close as "recommendation". Consider helping OP by editing their title into better shape (I would do it myself, but couldn't figure how, this probably needs better understanding of technical matters involved) – gnat Jan 3 '16 at 10:01

What you are looking for is probably Websockets. That will let you maintain a connection with the server, and send & receive data. Its very easy to implement on the client side.

Not the answer you're looking for? Browse other questions tagged or ask your own question.