Wowza Community

Unable to create Wowza CDN HLS Target

This is my Java Code, first I am creating StreamTarget in cloud.wowza.com, I want to pass the return value to the Wowza Streaming Engine CDN target…

When I run the code it is giving file not found error. It looks the something wrong with the URL, can anyone help on this.

StreamTargetsApi apiInstance = new StreamTargetsApi();<br><br>StreamTargetWowza targetWowza = new StreamTargetWowza();<br>targetWowza.setName(fixtureId);<br>targetWowza.setUseSecureIngest(true);<br>targetWowza.setStreamName(fixtureId);<br><br>targetWowza.setProvider(StreamTargetWowza.ProviderEnum.AKAMAI_CUPERTINO);

try {<br>    result = apiInstance.createWowzaStreamTarget(targetWowza); //This is working perfectly able to create the StreamTarget in cloud.wowza.com

//Now I want to pass the result value to Streaming enging. But getting error File not found error

    URL url = new URL("http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/pushpublish/mapentries/"+result.getName());

    getResponseFromHttpUrl(url,result.getConnectionCode(),result.getName(),result.getStreamName(),result.getId(),result.getHlsPlaybackUrl());
    return result;

} catch (ApiException e) {
    System.err.println("Exception when calling StreamTargetsApi#createWowzaStreamTarget");
    System.err.println("Exception when calling StreamTargetsApi#Code:"+e.getCode());
    System.err.println("Exception when calling StreamTargetsApi#ResponseBody:"+e.getResponseBody());
    e.printStackTrace();
}
private static String getResponseFromHttpUrl(URL url, String strConnectionCode, String entryName, String sourceStreamName, String targetid, String playbackurl) throws IOException {

    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("POST");
    connection.addRequestProperty("Accept","application/json");
    connection.addRequestProperty("Content-Type","application/json");
    connection.addRequestProperty("connectionCode",strConnectionCode);
    connection.addRequestProperty("enabled","true");
    connection.addRequestProperty("entryName",entryName);
    connection.addRequestProperty("profile","wowza-cdn");
    connection.addRequestProperty("sourceStreamName",sourceStreamName);
    connection.addRequestProperty("wowzaCloud.adaptiveStreaming","false");
    connection.addRequestProperty("wowzaCloud.accountApiKey","FZQ****");
    connection.addRequestProperty("wowzaCloud.accountAccessKey","Wn0****");
    connection.addRequestProperty("wowzaCloud.targetId",targetid);
    connection.addRequestProperty("hls_playback_url",playbackurl);
    try {
        InputStream in = connection.getInputStream();

        Scanner scanner = new Scanner(in);
        scanner.useDelimiter("\\A");

        boolean hasInput = scanner.hasNext();
        if (hasInput) {
            return scanner.next();
        } else {
            return null;
        }
    } catch (Exception e){
        Log.e("Error",e.toString());
    }

    finally {
        connection.disconnect();
    }
    return null;
}

Hello, what documentation were you following to set this up?