CRITICAL BUG, Missing event for network.request

On Build #971

I have a very peculiar issue.

It seems that my network listener just flat out does not recieve events from the server, even when it successfully reached the server and the server responded. How do I know the server recieved and responded to the information? Because it sends an email every time this specific thing occurs. I programmed into a custom timeout function as the app would Wait Forever to recieve information from the server.

This is a serious bug as I should always get atleast a time out from corona if it waited too long, but hte fact that the server processed an email based on my request proves to me that this is a bug in the system.

I would also like to point out that for it to recieve an email the server has to have already echoed a response.

[import]uid: 100738 topic_id: 33610 reply_id: 333610[/import]

I’m using 971, and am receiving responses from my server…

Is it just the reply/acknowledge of the call from your app to your servers sendmail.php that’s missing, or do you get no responses for all app calls to your server?

As far as your last point, that the server has to have echoed a response because it sent an email – I don’t think that’s true… The server can send an email, and still not reply to your network.request call if it wants, or it could be mis-configured, or perhaps some router / filter in-between blocking your inbound traffic/ports for the reply… (I’ve got some things going on different ports…)

Also, some type of malformed echoed response to the network.request could cause also cause the reply to fail I would think… [import]uid: 79933 topic_id: 33610 reply_id: 133611[/import]

I’ve been using 971 (and now 972), and I haven’t had any problem getting responses from my server via network.request – so I think, as @mpappas suggests, you might want to check to see if there’s anything wrong with the way the response is sent back to your app.

That said, has it ever worked before and did it suddenly stop working as soon as you started using 971? If you revert back to older Corona build, does it start working again?

Naomi [import]uid: 67217 topic_id: 33610 reply_id: 133615[/import]

hello there,

it echoes the response before it sends the email and even then the emails still get sent, implying that it processed everything correctly. I dont really send anything complicated just a set of numbers separated by commas which is then URL encoded.

The problem is that it works 80% of the time and 20% of the time corona does not receive a network event. This is a critical problem because the server is actually receiving the information, implying that corona is losing the data some how.

I print all objects in event and i receive nothing yet the email gets sent, the php script also is fool proof as the output is basically as follows.

Echo "{success}";  
sendEmail();  

I don’t know if this is a bug or a source of the problem but my function is part of a table listener which is as follows:

[code]
A.magic_handler = function(event)
local xml = xmlParser.newParser()
if A.type ~= “TheStore” and A.type ~= “ShoppingList” then
print_r(event)
end
local test_for_error = string.sub(event.response,1,1)
if event.isError then
local function onComplete( event )
if “clicked” == event.action then
local i = event.index
if 1 == i then
A:Request({A.type})
print(“YES”)
end
end
end
A.requestTypes[A.type].isError = true
A.requestTypes[A.type].isProcessing = false
if A.requestTypes[A.type].overide then
else
native.showAlert(“Connection”,“Network Timeout, please try again”, {“Try Again”},onComplete)
timer.performWithDelay(1000,A:Request({A.type}) )
end
elseif test_for_error ~= “{” then
A.requestTypes[A.type].isError = true
A.requestTypes[A.type].isProcessing = false
print(“OK”)
– print_r(event)
native.showAlert(“Bad Code”,“There was an issue with our server, tell RYAN that “”…A.type…”.php" is not working! Send him this very message: “…event.response, {“OK”})
elseif event.status == 500 then
A.requestTypes[A.type].isError = true
A.requestTypes[A.type].isProcessing = false
print(“OK”)
– print_r(event)
native.showAlert(“Very Bad Code”,“There was an issue with our server, tell RYAN that “”…A.type…”.php” is not working at all!!!", {“OK”})
else
A.requestTypes[A.type].isError = false

local response = json.decode(event.response

if response.Type == “TheStore” then
A.parse_for_TheStore( response )
elseif response.Type == “ShoppingList” then
A.parse_for_ShoppingList( response )
elseif response.Type == “AroundMe” then
A.parse_for_AroundMe( response )
elseif response.Type == “Confirmation” then
A.parse_for_Confirmation(response)
elseif A.type == “prizes” then
A.parse_for_prizes( event.response )
elseif A.type == “rankings” then
A.parse_for_rankings( response,event.response )
elseif A.type == “login” then
–the response is not in xml so just pass in the response
A.parse_for_login( event.response )
elseif A.type == “last pick” then
A.parse_for_lastpick(response,event.response)
elseif A.type == “past performance” then
A.parse_for_performance(response,event.response)
elseif A.type == “submission” then
A.parse_for_submission_response(response,event.response)
elseif A.type == “busy” then
A.parse_for_busy(response,event.response)
elseif A.type == “action_box” then
print(“action_box function switch”)
A.parse_for_action_box(response,event.response)
elseif A.type == “notifications” then

end
end
end
[/code] [import]uid: 100738 topic_id: 33610 reply_id: 133618[/import]

What would be a malformed echoed respose? I dont even get events sometimes. actaully a few times I did not recieve an event.response but the app some how pushed through normally… [import]uid: 100738 topic_id: 33610 reply_id: 133620[/import]

Hello Christian,
As Naomi asked, was this ever working? Are you saying “this worked in build 964 but not in build 971.” OR are you saying “this doesn’t work, and I happen to be testing in build 971.” ?

At first glance, I see a few things that appear to be errors, including a syntax error on line 43 (you didn’t close the parentheses). I see other odd coding things too, in various places. This is why I ask, did it ever work? If not, some careful debugging and syntax checking throughout, line by line, might narrow down the problem.

Best of luck!
Brent
[import]uid: 200026 topic_id: 33610 reply_id: 133625[/import]

@Christian - by malformed echo response I mean a server side php code error that breaks the echo statement (invalid syntax/expression type thing, null string) that I have seen causing my event.response to come back from the server as blank. There could also just be a general server side error in the handler that causes problems too…

If the server side error was very bad, I would suppose it could nuke the entire response, and you might not even get an event/reply at all (much less just a blank one). Various states on the server side, caused by the variables you pass in, could trigger the error, and the server side function might never complete. Even though you just send “{success}”, I don’t know how a php server might act in finishing/transmitting the echo and entire reply to the app for that particular call (you crashed the server thread possibly, and the echo might not have made it out).

I have no idea if this is what’s happening to your app though. just saying, I’ve seen empty event.response sometimes when there’s a server side error (on edge cases, or when my app sends bad data and the server code chokes)…

And as Naomi and Brent asked, does it happen with older builds? If so, then it is not build 971s fault… [import]uid: 79933 topic_id: 33610 reply_id: 133626[/import]

I would do a print_r(event) at the very top of your event handler.

I would also as a test, hit your server URL with a web browser (perhaps several times) to make sure it’s outputting what you expect it to output.
[import]uid: 199310 topic_id: 33610 reply_id: 133668[/import]

I see the problem, its taking too long for the app to catch it some times, it took me 15 tries though

33 seconds is 3 seconds longer then the app times out, thank you for the help! I will now fix this on the server side.

http://s10.postimage.org/70q41ihs5/Screen_Shot_2012_12_04_at_12_42_59_PM.jpg [import]uid: 100738 topic_id: 33610 reply_id: 133698[/import]

I’m using 971, and am receiving responses from my server…

Is it just the reply/acknowledge of the call from your app to your servers sendmail.php that’s missing, or do you get no responses for all app calls to your server?

As far as your last point, that the server has to have echoed a response because it sent an email – I don’t think that’s true… The server can send an email, and still not reply to your network.request call if it wants, or it could be mis-configured, or perhaps some router / filter in-between blocking your inbound traffic/ports for the reply… (I’ve got some things going on different ports…)

Also, some type of malformed echoed response to the network.request could cause also cause the reply to fail I would think… [import]uid: 79933 topic_id: 33610 reply_id: 133611[/import]

I’ve been using 971 (and now 972), and I haven’t had any problem getting responses from my server via network.request – so I think, as @mpappas suggests, you might want to check to see if there’s anything wrong with the way the response is sent back to your app.

That said, has it ever worked before and did it suddenly stop working as soon as you started using 971? If you revert back to older Corona build, does it start working again?

Naomi [import]uid: 67217 topic_id: 33610 reply_id: 133615[/import]

hello there,

it echoes the response before it sends the email and even then the emails still get sent, implying that it processed everything correctly. I dont really send anything complicated just a set of numbers separated by commas which is then URL encoded.

The problem is that it works 80% of the time and 20% of the time corona does not receive a network event. This is a critical problem because the server is actually receiving the information, implying that corona is losing the data some how.

I print all objects in event and i receive nothing yet the email gets sent, the php script also is fool proof as the output is basically as follows.

Echo "{success}";  
sendEmail();  

I don’t know if this is a bug or a source of the problem but my function is part of a table listener which is as follows:

[code]
A.magic_handler = function(event)
local xml = xmlParser.newParser()
if A.type ~= “TheStore” and A.type ~= “ShoppingList” then
print_r(event)
end
local test_for_error = string.sub(event.response,1,1)
if event.isError then
local function onComplete( event )
if “clicked” == event.action then
local i = event.index
if 1 == i then
A:Request({A.type})
print(“YES”)
end
end
end
A.requestTypes[A.type].isError = true
A.requestTypes[A.type].isProcessing = false
if A.requestTypes[A.type].overide then
else
native.showAlert(“Connection”,“Network Timeout, please try again”, {“Try Again”},onComplete)
timer.performWithDelay(1000,A:Request({A.type}) )
end
elseif test_for_error ~= “{” then
A.requestTypes[A.type].isError = true
A.requestTypes[A.type].isProcessing = false
print(“OK”)
– print_r(event)
native.showAlert(“Bad Code”,“There was an issue with our server, tell RYAN that “”…A.type…”.php" is not working! Send him this very message: “…event.response, {“OK”})
elseif event.status == 500 then
A.requestTypes[A.type].isError = true
A.requestTypes[A.type].isProcessing = false
print(“OK”)
– print_r(event)
native.showAlert(“Very Bad Code”,“There was an issue with our server, tell RYAN that “”…A.type…”.php” is not working at all!!!", {“OK”})
else
A.requestTypes[A.type].isError = false

local response = json.decode(event.response

if response.Type == “TheStore” then
A.parse_for_TheStore( response )
elseif response.Type == “ShoppingList” then
A.parse_for_ShoppingList( response )
elseif response.Type == “AroundMe” then
A.parse_for_AroundMe( response )
elseif response.Type == “Confirmation” then
A.parse_for_Confirmation(response)
elseif A.type == “prizes” then
A.parse_for_prizes( event.response )
elseif A.type == “rankings” then
A.parse_for_rankings( response,event.response )
elseif A.type == “login” then
–the response is not in xml so just pass in the response
A.parse_for_login( event.response )
elseif A.type == “last pick” then
A.parse_for_lastpick(response,event.response)
elseif A.type == “past performance” then
A.parse_for_performance(response,event.response)
elseif A.type == “submission” then
A.parse_for_submission_response(response,event.response)
elseif A.type == “busy” then
A.parse_for_busy(response,event.response)
elseif A.type == “action_box” then
print(“action_box function switch”)
A.parse_for_action_box(response,event.response)
elseif A.type == “notifications” then

end
end
end
[/code] [import]uid: 100738 topic_id: 33610 reply_id: 133618[/import]

What would be a malformed echoed respose? I dont even get events sometimes. actaully a few times I did not recieve an event.response but the app some how pushed through normally… [import]uid: 100738 topic_id: 33610 reply_id: 133620[/import]

Hello Christian,
As Naomi asked, was this ever working? Are you saying “this worked in build 964 but not in build 971.” OR are you saying “this doesn’t work, and I happen to be testing in build 971.” ?

At first glance, I see a few things that appear to be errors, including a syntax error on line 43 (you didn’t close the parentheses). I see other odd coding things too, in various places. This is why I ask, did it ever work? If not, some careful debugging and syntax checking throughout, line by line, might narrow down the problem.

Best of luck!
Brent
[import]uid: 200026 topic_id: 33610 reply_id: 133625[/import]

@Christian - by malformed echo response I mean a server side php code error that breaks the echo statement (invalid syntax/expression type thing, null string) that I have seen causing my event.response to come back from the server as blank. There could also just be a general server side error in the handler that causes problems too…

If the server side error was very bad, I would suppose it could nuke the entire response, and you might not even get an event/reply at all (much less just a blank one). Various states on the server side, caused by the variables you pass in, could trigger the error, and the server side function might never complete. Even though you just send “{success}”, I don’t know how a php server might act in finishing/transmitting the echo and entire reply to the app for that particular call (you crashed the server thread possibly, and the echo might not have made it out).

I have no idea if this is what’s happening to your app though. just saying, I’ve seen empty event.response sometimes when there’s a server side error (on edge cases, or when my app sends bad data and the server code chokes)…

And as Naomi and Brent asked, does it happen with older builds? If so, then it is not build 971s fault… [import]uid: 79933 topic_id: 33610 reply_id: 133626[/import]

I would do a print_r(event) at the very top of your event handler.

I would also as a test, hit your server URL with a web browser (perhaps several times) to make sure it’s outputting what you expect it to output.
[import]uid: 199310 topic_id: 33610 reply_id: 133668[/import]

I see the problem, its taking too long for the app to catch it some times, it took me 15 tries though

33 seconds is 3 seconds longer then the app times out, thank you for the help! I will now fix this on the server side.

http://s10.postimage.org/70q41ihs5/Screen_Shot_2012_12_04_at_12_42_59_PM.jpg [import]uid: 100738 topic_id: 33610 reply_id: 133698[/import]

OK,

I removed the too long issue but a tester has confirmed with me that the issue still exists.

Unrelated issue,

My tester claims that the app is pulling in massive amounts of data when it runs in the background. I dont have push notifications or anything, plus I am not sure how to even run things in the background on corona. He claims the app has used 1 gigabyte of data over the past month.

[import]uid: 100738 topic_id: 33610 reply_id: 133975[/import]

OK,

I removed the too long issue but a tester has confirmed with me that the issue still exists.

Unrelated issue,

My tester claims that the app is pulling in massive amounts of data when it runs in the background. I dont have push notifications or anything, plus I am not sure how to even run things in the background on corona. He claims the app has used 1 gigabyte of data over the past month.

[import]uid: 100738 topic_id: 33610 reply_id: 133975[/import]

Hi Christian,
As far as I know, Corona doesn’t “run in the background”, so I’m not sure how it would be sending/receiving data while the app is suspended, especially if you don’t have push notifications or anything else going on. I might be wrong about this and I can research it further if you’re still having this issue and your testing indicates massive amounts of data being transferred.

I assume you stop the network listener when the app suspends? I wouldn’t think this is necessary, but it could be, and it’s worth testing out.

Brent
[import]uid: 200026 topic_id: 33610 reply_id: 134250[/import]