# Mediacache on Amazon S3

**URL:** <https://community.wowza.com/t/mediacache-on-amazon-s3/39608>\
**Category:** Wowza Streaming Engine\
**Tags:** server-administration\
**Created:** [October 18, 2013, 2:56pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608 "2013-10-18T14:56:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paolo\_Latella1](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@Paolo\_Latella1](https://community.wowza.com/u/Paolo_Latella1)\
**Post date:** [October 18, 2013, 2:56pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/1 "2013-10-18T14:56:41Z")

</div>

Dears,

we have a Wowza instance on AWS with mediacache add-on installed. I try to stream a mp4 file from S3 bucket but get the error

WARN server comment 2013-10-17 16:20:50 - - - - - 1951.662 - - - - - - - s3/s3-eu-west-1.amazonaws.com/wowzastreamingdemo/test.mp4 MediaReaderH264.open[1]: java.io.IOException: MediaCacheRandomAccessReader.open: Item not in cache: s3/s3-eu-west-1.amazonaws.com/wowzastreamingdemo/test.mp4

I have a bucket on s3 with this url: [https://s3-eu-west-1.amazonaws.com/wowzastreamingdemo/test.mp4](https://s3-eu-west-1.amazonaws.com/wowzastreamingdemo/test.mp4)

and my MediaCache.xml file is this:

```auto
<MediaCacheSource>
                        <Name>http</Name>
                        <BasePath>https://</BasePath>
                        <Prefix>s3/</Prefix>
                        <BaseClass>com.wowza.wms.plugin.mediacache.impl.MediaCacheItemHTTPImpl</BaseClass>
                        <ReaderClass></ReaderClass>
                        <DefaultBlockSize>256K</DefaultBlockSize>
                        <MaxTimeToLive>1200000</MaxTimeToLive>
                        <MinTimeToLive>600000</MinTimeToLive>
                        <ReadAhead>true</ReadAhead>
                        <ReadAheadThreshold>50</ReadAheadThreshold>
                        <IsPassThru>false</IsPassThru>
                        <Properties>
                                <!-- maximum number of concurrent connections this source will make back to the web server -->
                                <Property>
                                        <Name>maxPoolSize</Name>
                                        <Value>25</Value>
                                        <Type>Integer</Type>
                                </Property>
                                <!-- HTTP request timeout -->
                                <Property>
                                        <Name>httpReadTimeout</Name>
                                        <Value>6000</Value>
                                        <Type>Integer</Type>
                                </Property>
                                <!-- HTTP connection timeout -->
                                <Property>
                                        <Name>httpConnectionTimeout</Name>
                                        <Value>6000</Value>
                                        <Type>Integer</Type>
                                </Property>
                                <!-- HTTP read request retry count -->
                                <Property>
                                        <Name>httpReadRetries</Name>
                                        <Value>3</Value>
                                        <Type>Integer</Type>
                                </Property>
                                <!-- Close socket connection if Content-Length incorrect on byte range request -->
                                <Property>
                                        <Name>closeConnectOnBadContentLength</Name>
                                        <Value>false</Value>
                                        <Type>Boolean</Type>
                                </Property>
                                <!-- HTTP send buffer size -->
                                 <Property>
                                        <Name>httpSendBufferSize</Name>
                                        <Value>8000</Value>
                                        <Type>Integer</Type>
                                </Property>
                                <!-- HTTP receive buffer size -->
                                <Property>
                                        <Name>httpReceiveBufferSize</Name>
                                        <Value>65000</Value>
                                        <Type>Integer</Type>
                                </Property>
                                <!-- Set to true if streaming from S3 so that bucket name is properly handled in URL structure -->
                                <Property>
                                        <Name>isAmazonS3</Name>
                                        <Value>true</Value>
                                        <Type>Boolean</Type>
                                </Property>
                                <Property>
                                        <Name>s3BucketNameInDomain</Name>
                                        <Value>false</Value>
                                        <Type>Boolean</Type>
                                </Property>
                                <!-- Uncomment and set properties if streaming from S3 authenticated -->
                                <!--
                                <Property>
                                        <Name>awsAccessKeyId</Name>
                                        <Value></Value>
                                </Property>
                                <Property>
                                        <Name>awsSecretAccessKey</Name>
                                        <Value></Value>
                                </Property>
                                -->
                                <!-- Uncomment and set these properties to send the request through a forward proxy server -->
                                <!--
                                <Property>
                                        <Name>proxyHost</Name>
                                        <Value></Value>
                                </Property>
                                <Property>
                                        <Name>proxyPort</Name>
                                        <Value></Value>
                                        <Type>Integer</Type>
                                </Property>requestFullURL
                                <Property>
                                        <Name>requestFullURL</Name>
                                        <Value>true</Value>
                                        <Type>Boolean</Type>
                                </Property>
                                -->
                        </Properties>
                </MediaCacheSource>

```

The url for playout is this

Server: rtmp://[wowza-address]/mediacache

Stream: mp4:s3/wowzastreamingdemo/test.mp4

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 18, 2013, 2:36pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/2 "2013-10-18T14:36:58Z")

</div>

Not sure why, but one quick and dirty way to get going for you will be to set /BasePath to “[https://s3-eu-west-1.amazonaws.com/](https://s3-eu-west-1.amazonaws.com/)” and isAmazonS3 to “false”. Then I can stream your test.mp4.

But let me look further, I don’t think the AWS keys will work with isAmazonS3 set to “false”

I tried setting s3BucketNameInDomain to “false”, but that did not work, and there isn’t a bucket name in the domain.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 18, 2013, 2:45pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/3 "2013-10-18T14:45:43Z")

</div>

This works:

```auto
<MediaCacheSource>
	                        <Name>http2</Name>
	                        <BasePath>http://s3.amazonaws.com/</BasePath>
	                        <Prefix>s3/</Prefix>
	                        <BaseClass>com.wowza.wms.plugin.mediacache.impl.MediaCacheItemHTTPImpl</BaseClass>
	                        <ReaderClass></ReaderClass>
	                        <DefaultBlockSize>256K</DefaultBlockSize>
	                        <MaxTimeToLive>1200000</MaxTimeToLive>
	                        <MinTimeToLive>600000</MinTimeToLive>
	                        <ReadAhead>true</ReadAhead>
	                        <ReadAheadThreshold>50</ReadAheadThreshold>
	                        <IsPassThru>false</IsPassThru>
	                        <Properties>
	                                <!-- maximum number of concurrent connections this source will make back to the web server -->
	                                <Property>
	                                        <Name>maxPoolSize</Name>
	                                        <Value>25</Value>
	                                        <Type>Integer</Type>
	                                </Property>
	                                <!-- HTTP request timeout -->
	                                <Property>
	                                        <Name>httpReadTimeout</Name>
	                                        <Value>6000</Value>
	                                        <Type>Integer</Type>
	                                </Property>
	                                <!-- HTTP connection timeout -->
	                                <Property>
	                                        <Name>httpConnectionTimeout</Name>
	                                        <Value>6000</Value>
	                                        <Type>Integer</Type>
	                                </Property>
	                                <!-- HTTP read request retry count -->
	                                <Property>
	                                        <Name>httpReadRetries</Name>
	                                        <Value>3</Value>
	                                        <Type>Integer</Type>
	                                </Property>
	                                <!-- Close socket connection if Content-Length incorrect on byte range request -->
	                                <Property>
	                                        <Name>closeConnectOnBadContentLength</Name>
	                                        <Value>false</Value>
	                                        <Type>Boolean</Type>
	                                </Property>
	                                <!-- HTTP send buffer size -->
	                                 <Property>
	                                        <Name>httpSendBufferSize</Name>
	                                        <Value>8000</Value>
	                                        <Type>Integer</Type>
	                                </Property>
	                                <!-- HTTP receive buffer size -->
	                                <Property>
	                                        <Name>httpReceiveBufferSize</Name>
	                                        <Value>65000</Value>
	                                        <Type>Integer</Type>
	                                </Property>
	                                <!-- Set to true if streaming from S3 so that bucket name is properly handled in URL structure -->
	                                <Property>
	                                        <Name>isAmazonS3</Name>
	                                        <Value>true</Value>
	                                        <Type>Boolean</Type>
	                                </Property>
	                                <Property>
	                                        <Name>s3BucketNameInDomain</Name>
	                                        <Value>true</Value>
	                                        <Type>Boolean</Type>
	                                </Property>
	                                <!-- Uncomment and set properties if streaming from S3 authenticated -->
	                                <!--
	                                <Property>
	                                        <Name>awsAccessKeyId</Name>
	                                        <Value></Value>
	                                </Property>
	                                <Property>
	                                        <Name>awsSecretAccessKey</Name>
	                                        <Value></Value>
	                                </Property>
	                                -->
	                                <!-- Uncomment and set these properties to send the request through a forward proxy server -->
	                                <!--
	                                <Property>
	                                        <Name>proxyHost</Name>
	                                        <Value></Value>
	                                </Property>
	                                <Property>
	                                        <Name>proxyPort</Name>
	                                        <Value></Value>
	                                        <Type>Integer</Type>
	                                </Property>requestFullURL
	                                <Property>
	                                        <Name>requestFullURL</Name>
	                                        <Value>true</Value>
	                                        <Type>Boolean</Type>
	                                </Property>
	                                -->
	                        </Properties>
                </MediaCacheSource>

```

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 18, 2013, 2:49pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/4 "2013-10-18T14:49:09Z")

</div>

I changed the MediaCacheSoure /Name to “http2” to avoid duplicate on your side.

I change /BasePath to “[http://s3.amazonaws.com/](http://s3.amazonaws.com/)”

And /isAmazonS3 and /s3BucketNameInDomain to “true”

Note that the The [Wowza EC2 pre-built AMIs](https://www.wowza.com/docs/pre-built-amis-amazon-machine-images%28amazon-machine-images%29) come with MediaCache installed and a MediaCache application named “vods3”.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 18, 2013, 3:50pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/5 "2013-10-18T15:50:43Z")

</div>

It’s working here. Did you restart Wowza? after making those changes? Did you use the MediaCache source I showed?

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 18, 2013, 4:32pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/6 "2013-10-18T16:32:36Z")

</div>

Using the Wowza example VideoOnDemand Flash RTMP player.

Server: rtmp://[wowza-address]:1935/mediacache

Stream: mp4:s3/wowzastreamingdemo/test.mp4

```auto
INFO session connect 0:0:0:0:0:0:0:1
INFO stream create 
INFO stream play s3/wowzastreamingdemo/test.mp4
INFO stream stop s3/wowzastreamingdemo/test.mp4
INFO stream destroy s3/wowzastreamingdemo/test.mp4

```

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 18, 2013, 4:55pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/7 "2013-10-18T16:55:39Z")

</div>

From what I can see in that screen shot you have left out “rtmp://”

Richard

---

<div class="post-metadata">

**Author:** ![Paolo\_Latella1](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@Paolo\_Latella1](https://community.wowza.com/u/Paolo_Latella1)\
**Post date:** [October 18, 2013, 4:40pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/8 "2013-10-18T16:40:30Z")

</div>

> I changed the MediaCacheSoure /Name to “http2” to avoid duplicate on your side.
> 
> I change /BasePath to “[http://s3.amazonaws.com/](http://s3.amazonaws.com/)”
> 
> And /isAmazonS3 and /s3BucketNameInDomain to “true”
> 
> Note that the The [Wowza EC2 pre-built AMIs](https://www.wowza.com/docs/pre-built-amis-amazon-machine-images%28amazon-machine-images%29) come with MediaCache installed and a MediaCache application named “vods3”.
> 
> Richard

The error persist

WARN server comment 2013-10-18 15:30:46 - - - - - 15.145 - - - - - - - s3/wowzastreamingdemo/test.mp4 MediaReaderH264.open[1]: java.io.IOException: MediaCacheRandomAccessReader.open: Item not in cache: s3/wowzastreamingdemo/test.mp4

---

<div class="post-metadata">

**Author:** ![Paolo\_Latella1](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@Paolo\_Latella1](https://community.wowza.com/u/Paolo_Latella1)\
**Post date:** [October 18, 2013, 5:27pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/9 "2013-10-18T17:27:44Z")

</div>

> It’s working here. Did you restart Wowza? after making those changes? Did you use the MediaCache source I showed?
> 
> Richard

Yes i have restarted Wowza and don’t work, can you send me the url for playout ?

---

<div class="post-metadata">

**Author:** ![Paolo\_Latella1](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@Paolo\_Latella1](https://community.wowza.com/u/Paolo_Latella1)\
**Post date:** [October 18, 2013, 5:41pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/10 "2013-10-18T17:41:52Z")

</div>

It’s very strange … look this

[https://docs.google.com/a/interact.it/file/d/0B6i1LiiHXZ7iWXVuRGdOazhCelE](https://docs.google.com/a/interact.it/file/d/0B6i1LiiHXZ7iWXVuRGdOazhCelE)

---

<div class="post-metadata">

**Author:** ![Paolo\_Latella1](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@Paolo\_Latella1](https://community.wowza.com/u/Paolo_Latella1)\
**Post date:** [October 18, 2013, 7:34pm UTC](https://community.wowza.com/t/mediacache-on-amazon-s3/39608/11 "2013-10-18T19:34:14Z")

</div>

> From what I can see in that screen shot you have left out “rtmp://”
> 
> Richard

The picture is cutted the url is rtmp://ec2-54-216-xxx-yyy.eu-west-1.compute.amazonaws.com/mediacache/mp4:s3/wowzastreamingdemo/test.mp4
