In summary, I think the issue was that you can not use the name "localhost" for your server name.
I checked that I had correctly setup all my ThingWorx items in Property Editor (Enabled, host name, port, application key, etc.) However, I kept having problems. I thought the problem was the application key, so i entered a bad application key and I got a different error (authentication error). I tried changing the socket from 9080 to the example's 8080 and got a socket error.
After going into the thingworx controls advisor and deleting the server and then adding a new server called "TestServer" instead of "localhost", it now works.
I'm writing this post in hope that either someone experiencing the same issue finds this useful, or that someone from thingworx comes across this post and is able to test if it is indeed an issue using the name "localhost" and then takes the appropriate action.