Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to stream data from client to server via http?

I'm wanting to stream data from a client (desktop or mobile) to a hosted server. It's not a large amount of data, 1 byte every 1/10 second - but the data needs to be streamed immediately (no buffering) and the connection needs to stay active for a long period of time (say 10 minutes max).

Because the server is hosted, I don't have the ability to use sockets - just http.

I know on the server side, if I was connecting to a client I can do this using persistent connections and just writing to the response stream.

But is there a way to do this in reverse, where a client has a persistent connection to the server and is writing to the request stream?

Clarification: I don't have to have this client->server communication done as persistent http connection, I was just wondering if it was possible, just so I could have symmetry with my planned server->client persistent http connection.

From what I'm hearing, it sounds like I should just be able to do individual http posts and achieve the same or similar latency.

like image 620
PhilChuang Avatar asked Nov 04 '22 01:11

PhilChuang


1 Answers

I'll go ahead and provide the answer to my own question, which seems to be:

It's technically possible to do a persistent http connection from client->server, but nobody's implemented it yet because using the normal method of creating individual http requests seems to be fast enough for everybody's purposes.

So that's what I ended up doing, simply using WebRequest.Create and the HttpWebRequest class and trusting that the framework is handling KeepAlive. And in my prototypes that seems to be fast enough, although real-world performance remains to be seen.

like image 169
PhilChuang Avatar answered Nov 09 '22 11:11

PhilChuang