11

I would like to stream data from the client to the server.

My application streams audio data to the server. I do not know how long the audio will be when I begin streaming it. I want to reduce latency by transmitting the data as it is being recorded. Once all the data has been uploaded, then I will process it.

So, what I would like is a HTTP POST where the body is streamed. At the client, the POST would be sent as the data is available. At the server end, I would like it to arrive like a normal POST with a complete body of collected data.

I am currently using Restlet, and implementing my stream as a Chunked POST to the Restlet framework.

However, I can not find a client API that allows me to begin the POST, then start streaming the data.

I haven't found anything useful searching the archive. Can anyone give me a pointer here. Can HTTP POST be used this way? Can I use Restlet for this? Is there another standard pattern/API for streaming from the client to the server?

Many thanks in advance Peter

opus111
  • 2,744
  • 4
  • 25
  • 41
  • 3
    Depending on the application / client the [Websocket protocol](http://en.wikipedia.org/wiki/WebSocket) might be interesting for you. – Stephan Dec 13 '12 at 21:31
  • Nice, Thanks Stephan. Does Websocket work on Android and iOS? – opus111 Dec 13 '12 at 22:06
  • Yes it does! jWebSockets looks very nice. Has anyone tried it? Other recommendations? – opus111 Dec 13 '12 at 22:10
  • On Android I have used [Weberknecht](http://code.google.com/p/weberknecht/) which however has not seen a release for some time now, so I am not sure whether it is still under development. For C++ I know about [WebSocket++](http://www.zaphoyd.com/software/websocket%2B%2B), however I never used it. – Stephan Dec 14 '12 at 07:31

2 Answers2

7

Going to answer my own question for those that come after.

Here is a nice tutorial on streaming requests with Apache HttpClient

Search for "Request Streaming:"

http://hc.apache.org/httpclient-3.x/performance.html#Request_Response_entity_streaming

opus111
  • 2,744
  • 4
  • 25
  • 41
-6

I can not find a client API that allows me to begin the POST

You could always use a browser. Serverside it's just the same a a file upload.

symcbean
  • 47,736
  • 6
  • 59
  • 94
  • 1
    Thanks, but I need to do this in my application. I want to make a laptop Java client for debugging, and then implement Android and iOS. – opus111 Dec 13 '12 at 22:22