Mediacache on Amazon S3

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

and my MediaCache.xml file is this:

<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

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/” 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

This works:

<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

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

I change /BasePath to “http://s3.amazonaws.com/

And /isAmazonS3 and /s3BucketNameInDomain to “true”

Note that the The Wowza EC2 pre-built AMIs come with MediaCache installed and a MediaCache application named “vods3”.

Richard

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

Richard

Using the Wowza example VideoOnDemand Flash RTMP player.

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

Stream: mp4:s3/wowzastreamingdemo/test.mp4

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

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

Richard

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

I change /BasePath to “http://s3.amazonaws.com/

And /isAmazonS3 and /s3BucketNameInDomain to “true”

Note that the The Wowza EC2 pre-built AMIs 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

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 ?

It’s very strange … look this

https://docs.google.com/a/interact.it/file/d/0B6i1LiiHXZ7iWXVuRGdOazhCelE

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