Pub/Sub Test

Here you can easily test pushing data to browsers with Fastly Pub/Sub. This page connects to the service using the JavaScript EventSource API.

Initializing...

Subcribing and Publishing

This page is using the following JavaScript to subscribe to events:

const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjRkYWFiMDA3In0.eyJ4LWZhc3RseS1yZWFkIjpbImJkNmJjMmJkIl0sIngtZmFzdGx5LXdyaXRlIjpbImJkNmJjMmJkIl0sImlhdCI6MTc0NTAzNzIzMCwiZXhwIjoxNzQ1MDQwODMwfQ.SB3zm3fwRgRTEjCheVD8sZ3rwnHxNxe0kgpOao5uqpM";

const es = new EventSource('https://pubsub-test.edgecompute.app/events?topic=bd6bc2bd&auth=' + token);
es.addEventListener('message', function (event) {
    $('#output').text(event.data);
}, false);

And here's a curl command that you can use to publish on your own. It contains an authentication token that lasts for 1 hour:

curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjRkYWFiMDA3In0.eyJ4LWZhc3RseS1yZWFkIjpbImJkNmJjMmJkIl0sIngtZmFzdGx5LXdyaXRlIjpbImJkNmJjMmJkIl0sImlhdCI6MTc0NTAzNzIzMCwiZXhwIjoxNzQ1MDQwODMwfQ.SB3zm3fwRgRTEjCheVD8sZ3rwnHxNxe0kgpOao5uqpM" -d "hello world" "https://pubsub-test.edgecompute.app/events?topic=bd6bc2bd"