1

I'd like to be able to send a message to a client from a node.js app, without using something like socket.io. For example, is it possible to send from the client an AJAX request that won't expire? Then, where there is data on the server side, I can use the that session to push the message to the client. Or may be, someone has better idea?

Of course polling from the client is the trivial answer, but I'd like to avoid this.

Thanks a lot in advance.

4
  • what's the problem with using socket.io ? Commented Feb 5, 2015 at 18:30
  • Hmm, I also wonder... Requirements.. :) Commented Feb 6, 2015 at 17:25
  • 1
    Sorry I was late. I am glad you found the solution in SSE. HTML5 SSE is definitely a great option. As an alternative, you could go pure HTML5 websockets, instead of wrapper like socket.io. Node has many packages that implement RFC 6455. Two of them that I am aware of are - Websocket Node - github.com/theturtle32/WebSocket-Node and WS - github.com/websockets/ws .. Both are available via NPM. Commented Feb 7, 2015 at 23:46
  • Thanks a lot. After checking all these technologies I managed to convince the team to use socket.io. Althout SSE seems to be fine, it looks like socket.io is most robust and frequently maintained. Also, I found that it can integrate with passport and redis for session management. Hope this will help if others are evaluating these options as well. Commented Feb 10, 2015 at 17:52

1 Answer 1

3

You can use Server-Sent Events. Here's a module that will handle the harder parts for you: https://www.npmjs.com/package/sse

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.