Archivio dei tag tech

Managing a web radio streaming provider

If you manage a Web Radio, if you are an IT consultant, or you’re just the “one of the tech guys” behind the scenes of such a radio, keep in mind the following suggestions. There could be some part of the web integration with your site that may result in future problems or a lot of work. Most of these problems are related to third-party services that you may or may not use, so let’s analyze some of them.

Streaming services

If you manage a Web Radio, you already know that you need a streaming web service in order to make people listen to your streaming audio. Unless you select an “all-in-house” solution, where you have a server with your website, your streaming server, and also podcast spaces, you probably rely on some third-party streaming services. This is also convenient from an economical point of view, because streaming servers can be very cheap, and some of them also come with an una-tantum solution (you paid once and only once). This basically means that your website has an url

https://www.myradiowebsite.com

While your streaming service has a different url, maybe something like this

https://stream.thirdparty.org:8021/stream

While this is a good solution and it works nicely without any problem, please consider that your streaming url (https://stream.thirdparty.org:8021/stream) may be used in multiple places: your website is one of them, but also your mobile app, your other integration with other websites, other webradio aggregator websites and so on.

The problem: streaming url 

When you use a streaming server provider, this basically means you are coupled to a streaming url and if you want to change your streaming server provider, you need to update everything with your new streaming url: your website, your mobile app, the webradio aggregator website (eg. Tunein). More than this, if you need more listeners, the only way of doing this is to pay your streaming server provider for an upgraded plan.

The solution: a redirect proxy

The solution is to set up a simple redirect that can be easily manageable in-house. The redirect should add a streaming URL owned in your website, so something like this:

https://www.myradiowebsite.com/mystreaming --redirect to--> https://stream.thirdparty.org:8021/stream

This can be achieved in different ways: the simplest could probably be adding a rule in your .htaccess file (if you have an apache hosting) or a directive in ngnix configuration, if your hosting supports nginx. The redirect syntax is not covered in this post, you could probably find the right ones just by looking on the internet. I want to cover a slightly different solution that uses a programmatic approach. It’s a PHP redirect solution, but I know that this can be done with any other server-side language. More than having just a redirect, I’ve added the possibility of a random weighted redirect. The idea is that you can set up a redirect that is randomly distributed, so if you have 2 streaming service providers…

server1 = https://my.webradioserver.com:8201/stream 
server2 = https://another.server.com/8020/stream

… you can then weigh for example set 50-50 so that a user could listen to server1 or to server2 with a 50% of probability. This gives you the chance to move to another server with a ramp up, or you can add another server to increase the possible listeners, and assign the user randomly . This is my solution: 

<?php header("Expires: on, 01 Jan 1970 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); function getRandomWeightedElement(array $weightedValues) { $rand = mt_rand(1, (int) array_sum($weightedValues)); foreach ($weightedValues as $key => $value) { $rand -= $value; if ($rand <= 0) { return $key; } } } $serverSTreaming1 = 'https://my.webradioserver.com:8201/stream'; $serverSTreaming2 = 'https://another.server.com/8020/stream'; $wheights = array($serverSTreaming1=>0, $serverSTreaming2=>100); header("location: ".getRandomWeightedElement($wheigths)); die();

The section
$wheights = array($serverSTreaming1=>0, $serverSTreaming2=>100);

does all the magic: this setup moves all the traffic to streaming $serverSTreaming2, but you can of course configure it at 50-50 as well, for example with

$wheights = array($serverSTreaming1=>50, $serverSTreaming2=>50);

This solution could easily be extended with more streaming providers and different weights.

Giveaways

With a redirect solution, you can easily change your streaming provider to all your clients like your website, your mobile application, third party web site aggregators etc. because you use the source url and then only change the redirect destination.

You can add multiple sources and weigh them, as per my example.

 

Amsterdam Codemotion 2019

 

Le foto del codemotion 2019 ad Amsterdam dove ho parlato insieme ad Annarita De Biase con un talk dal titolo “The story of unconventional testing solution”. Un talk sul perché e su quali motivi possono spingere un tester a sviluppare un proprio strumento di test invece che utilizzare uno di quelli già sul mercato.

 

WebSummit 2017

Grazie ad un concorso ho avuto la possibilità di partecipare al websummit 2017 a Lisbona. Si tratta di una delle più grandi manifestazioni legate al mondo del web. Stiamo parlando di 60mila partecipanti, 4 padiglioni più un arena. Eventi come workshop, presentazioni, pitch, argomenti tecnici e ispirazionali.

Alla presentazione c’è stato l’intervento di Stephen Hawking…ecco per dire.

L’intelligenza artificiale può essere la più grande opportunità del futuro o portarci alla rovina. Stephen Hawking

Si è parlato molto di Intelligenza artificiale, di quello che può fare e di come ci sia bisogno di un etica regolamentatrice dietro, si è parlato di giustizia legale con il commissario Europeo che ha multato i giganti del web (google, facebook, apple).

Ho visto la presentazione delle auto volanti di UberFlight (no, non c’erano auto volanti…è un progetto..ci vuole un po’, ma ecco, io c’ero quando l’hanno detto).

Ho fatto cose tecniche come seminari su argomenti che non sto a spiegare, ma ho anche conosciuto persone del mio ambiente, del marketing, dei competitor.

Ho anche visitato la bella città di Lisbona, per la terza volta a dire il vero, ma andava comunque rifatta la visita. Tra l’altro sono riuscito a mangiare i pasteis de nata alla famosa pasticceria, finalmente! che le altre volte c’era una fila…..

Si, sono anche uscito ed è lì che ho, anzi abbiamo perchè ero con il collega e amico Giuseppe, fatto conoscenze e incontrato persone da tutto il mondo.

 

Qualche link utile

websummit.com la manifestazione che ho seguito

Golden Tram 242 il posto dove ho dormito, si è un ostello. E la cosa va bene così! (anche qui)

1 de Maio ristorante a Lisbona