700 Software
700 Software

Reputation: 87783

Node.JS: stream HTTP client request body?

I want to create a two-way stream between a Node.JS client and a Node.JS server, via an HTTP connection. But it seems that the server's request event is not called until the client calls req.end(). How can I establish a two-way communication? Do I need to use separate requests?

Clarification: My expectation was that it was possible for

  1. The client to send the request header,
  2. The server to send the response header, and
  3. The server and client to send bytes whenever they want.

Edit: OK, here is the summary of the options:

Upvotes: 0

Views: 1965

Answers (1)

Evert
Evert

Reputation: 99533

If you are really looking for a 2-way communication system, HTTP is not really the correct protocol.. The whole idea is that it's stateless and handled 1 request at a time. There's exceptions to this rule, but those are really stretching what HTTP is supposed to do, and could be considered hacks.

It sounds like you should be using something like Socket.IO

Upvotes: 2

Related Questions