Corona Simulator (Windows) network request receives isError for my Web site

Hello,

Edit: I put this in the wrong category. It should be in “Network” rather than “Game Networking” and I realized it as soon as I submitted it.

I am running into an odd issue and I am unsure of how to debug it further. I run identical code on multiple devices:

  1. Corona Simulator (Windows)

  2. Corona Simulator (Windows)

  3. Corona Simulator (Mac)

4-8) 5 iPhones

Here is the code that runs on each of these eight 

local url = "http://www.hook-shots.com/app/testConnection.php" local headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept-Language"] = "en-US"; local params = {} params.headers = headers params.body = "" network.request(url,"POST",networkListener,params)

And the networkListener() method referenced above:

 local function networkListener(event) if event.isError then print("checkConnection isError") self.onlineMode = false elseif string.sub(event.response,1,18) == "CONNECTION\_SUCCESS" then print("checkConnection found CONNECTION\_SUCCESS") end end

On devices 3-8, I have never had any issue with this. It returns CONNECTION_SUCCESS and prints the success string to the console.

Device 1 (Corona Simulator on a Windows machine) worked fine for weeks. Then over the weekend, running the same code, I began receiving event.isError = true and “checkConnection isError” prints to the console.

I was getting a new laptop anyway (Device 2) and it came today. It also receives isError = true and prints the error message.

Devices 3-8 still work without issue.

Without seeing any detail behind this network request, it is hard for me to determine what is going on. What makes it especially strange is that it works, running the same application, from several other devices. Also, Device 1 and Device 2 receive isError for any URL within hook-shots.com. But if you change the url variable to “http://www.google.com” it receives the data back successfully.

The site receiving the error is a site on a GoDaddy shared hosting plan. I tried contacting their support staff about the issue but they were unable to find any issue on their side, as they could connect to the URL successfully from every source they could attempt.

The issue seems to be narrowed down specifically to Corona Simulator and to URLs at this site, but without being able to see the inner workings/details of the network request from either side, I am having trouble debugging this.

Has anyone else run into and/or overcome an issue like this with Corona Simulator and a Web site? Does anyone have any suggestions for what I could try to move past this error?

After giving this more thought, I realized that I had a working request and a failing request from the same source computer (e.g. “Device 2”, a Windows laptop) and I could use a packet sniffer to see what the differences are in the two requests. So I used Wireshark to compare the working request from Google Chrome’s Advanced REST Client to the failing request from Corona Simulator.

After some trial and error, I was able to determine that I could get my Corona Simulator request to work if I added a “User-Agent” header with any non-blank value. Even if I put a random value, like “zzzz” in, the request returned successfully.

So the working code ended up being:

local url = "http://www.hook-shots.com/app/testConnection.php" local headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept-Language"] = "en-US"; headers["User-Agent"] = "zzzz"; local params = {} params.headers = headers params.body = "" network.request(url,"POST",networkListener,params)

I don’t even have a working theory as to why this fixed the problem, nor do I know why I only even had the problem from 2 of my 8 devices. However, it was able to get my Simulator working again with network requests to my Web site. Hopefully this is helpful for anyone else who runs into a similar problem.

After giving this more thought, I realized that I had a working request and a failing request from the same source computer (e.g. “Device 2”, a Windows laptop) and I could use a packet sniffer to see what the differences are in the two requests. So I used Wireshark to compare the working request from Google Chrome’s Advanced REST Client to the failing request from Corona Simulator.

After some trial and error, I was able to determine that I could get my Corona Simulator request to work if I added a “User-Agent” header with any non-blank value. Even if I put a random value, like “zzzz” in, the request returned successfully.

So the working code ended up being:

local url = "http://www.hook-shots.com/app/testConnection.php" local headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept-Language"] = "en-US"; headers["User-Agent"] = "zzzz"; local params = {} params.headers = headers params.body = "" network.request(url,"POST",networkListener,params)

I don’t even have a working theory as to why this fixed the problem, nor do I know why I only even had the problem from 2 of my 8 devices. However, it was able to get my Simulator working again with network requests to my Web site. Hopefully this is helpful for anyone else who runs into a similar problem.