0

I am trying to stream video from my webapp that is running on Tomcat7. The video stream is initiated by a HTML5 video tag which is also fed by the tomcat webapp. My solution so far is pretty straight forward. When a request for the video file comes to my HttpServletRequests doPost() I do some checks and then read the contents of the actual file and write them to the HttpServletResponse getOutputStream() using a read /write loop and a 64k buffer. The videos I am using for tests are in mp4 and ogv format and about 80mb in size.

It works fine in my test environment (local tomcat on ubuntu system) but does not on my web server. Unfortunately my server setup is a bit more complex and of course the networking is a bit slower than via localhost.. The server has an apache 2.2 as front end that basically does a bit of manipulation via mod_rewrite (redirecting most requests to https), does the tls processing and forwards the request to the tomcat via mod_jk/ajp13.

It seems stupid to stream video through tls but the rest of the site is tls. I tried to do the video request via plain http but then I am loosing my session information which I was wanting to use to restrict access to some of the video files to logged on users. It also did not seem to help the problem.

Using this setup the videos do not play and on several occasions the web server developed several apache processes going wild which sent the server into overload and basically finished it off (temporarily not available) until I restarted the tomcat.

My questions are as follows:

  • I have not gathered much information about video streaming to HTML5 but is it really as simple as writing the video file to the HttpServletResponse output stream?

  • My problem persists if I do not send the stream through tls (but still through mod_jk). Does it make any sense to send streaming data through tls? What might be the overhead ?

  • Has anyone got experience with streaming through mod_jk ? Does it make sense, are there special configuration requirements for streaming ?

Thomas
  • 311
  • 2
  • 17
  • forget video player; try access the URL directly, and see what is sent to the browser. – ZhongYu Sep 09 '15 at 22:43
  • and if this kills your server (videos are usually long requests), you better look for some NIO solution. – ZhongYu Sep 09 '15 at 22:47
  • Just wonder why do you utilize mod_jk while tomcat/java itself is good enough in secure things! it make sense to transmit stream with tls, but having more layer makes your system too heavy. you also go for NIO for streaming, or get some hand of CDNs –  Sep 09 '15 at 23:02
  • @user5266804 The server hosts several other websites which do not utilize tomcat so apache is the front end anyway. To use tomcat without apache and mod_jk I would have to go through an alternate port (eg. 8080) which is a bit ugly but probably no show stopper.. Apart from that I was just too lazy to set up tomcat tls and I am not sure if my cheap ssl certificate would work both on port 80 and 8080.. – Thomas Sep 09 '15 at 23:28
  • @bayou.io I guess thats what I will have to do. I had a short look at java nio and did not quite see how it would improve my problem. I actually used a nio copy function (copied from some sample) before I decided to do the copying myself in the process of debugging the problem.. – Thomas Sep 09 '15 at 23:48
  • `I was just too lazy to set up tomcat tls` awesome! you may acquire new ip address and let tomcat rule it as port 80 and 443, it will help you and your system too much, tomcat and jre won't sue you about cheap certs I believe. –  Sep 10 '15 at 00:03

0 Answers0