REST API race condition

I am using the /publishers REST API with Wowza Streaming Engine 4.4.1.

I have noticed that it is possible to generate what appears to be a race condition. This sequence of cURL commands run in immediate succession should result in zero publishers, but does not (response inlined).

HOST=localhost

PORT=8087

$ curl -X GET “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’

{“serverName”:“defaultServer”,“publishers”:[]}

$ curl -X POST “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers/A” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ --data ‘{“name”:“n”, “password”:“pw”}’

{“success”:true,“message”:"",“data”:null}

$ curl -X DELETE “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers/A” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’

{“success”:true,“message”:“Saved”,“data”:null}

$ curl -X GET “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’

{“serverName”:“defaultServer”,“publishers”:[{“name”:“A”}]}

The DELETE call gets a successful response (vs a 404) indicating that user “A” was found and deleted successfully.

Furthermore, by making rapid requests in succession, we can get multiple users with the same user name saved (which should be disallowed).

If you run the following set of commands you will see indeterminate results, but often, you will see multiple user “A” reported back at the end (such as {“serverName”:“defaultServer”,“publishers”:[{“name”:“A”},{“name”:“A”}]}).

curl -X GET “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’

curl -X POST “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers/A” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ --data ‘{“name”:“n”, “password”:“pw”}’

curl -X DELETE “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers/A” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’

curl -X POST “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers/A” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ --data ‘{“name”:“n”, “password”:“pw”}’

curl -X POST “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers/A” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ --data ‘{“name”:“n”, “password”:“pw”}’

curl -X DELETE “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers/A” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’

curl -X POST “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers/A” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ --data ‘{“name”:“n”, “password”:“pw”}’

curl -X GET “http://${HOST}:${PORT}/v2/servers/defaultServer/publishers” -H ‘Content-Type: application/json’ -H ‘Accept: application/json’

In both scenarios, putting a “sleep 1” command between the calls results in consistently correct behavior.

Hello there and welcome to the Wowza support forum.

Thank you for your due diligence in raising this issue and provided details. I am sure the Wowza dev team will take this under consideration.

Regards,

Salvadore