Question

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.

Était-ce utile?

La solution

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.

Autres conseils

Perhaps a WebSocket would be useful. It lets you create a "socket" over HTTP, so you can use it to send data from the client to the server over HTTP.

I'm not sure if this is a good use case, but SignalR might work for you.

AFAIK, streaming doesn't work when WCF is hosted in IIS.

I found this CodeProject article that says it's fixed in WCF 4.5.

Can you get the client to make new calls every 1/10 sec? The TCP connection should be held open if you're using HTTP 1.1.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top