# REST API race condition

**URL:** <https://community.wowza.com/t/rest-api-race-condition/47076>\
**Category:** Wowza Developer Dojo\
**Created:** [May 21, 2016, 2:44pm UTC](https://community.wowza.com/t/rest-api-race-condition/47076 "2016-05-21T14:44:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kamran\_Kashef](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kamran\_Kashef](https://community.wowza.com/u/Kamran_Kashef)\
**Post date:** [May 21, 2016, 2:44pm UTC](https://community.wowza.com/t/rest-api-race-condition/47076/1 "2016-05-21T14:44:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sal\_jefferson](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sal\_jefferson](https://community.wowza.com/u/sal_jefferson)\
**Post date:** [June 9, 2016, 5:15am UTC](https://community.wowza.com/t/rest-api-race-condition/47076/2 "2016-06-09T05:15:30Z")

</div>

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
