Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

network.request POST occasionally returning event.status == -1
Started by akao Dec 05 2018 10:07 PM

3 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

akao

[GLOBAL: userInfoPane.html]
akao
  • Contributor

  • 342 posts
  • Corona SDK

We have an app in production. In our error logging system we noticed that occasionally, one of our network.request POST call will return with an event.status==-1. It feels like this is something that Corona itself may be sending back (rather than the server). So, I am trying to figure out if this is something I should worry about. Or, is this just a standard status if Corona can't connect to the server? 

 

Many thanks,

Andrew 



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 368 posts
  • Corona SDK

Unless I remember wrong, -1 is a status code that you can get due to network issues, such failing to connect to a remote host or not receiving a response back from the remote host.

I'd double check your server side code and settings.



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,997 posts
  • Corona SDK

Are you testing the event.isError value?

 

The event.status should have the HTTP response code from the server. These are codes like 200 - Success, 404 - Resource not found, 500 - Internal Server Error. The presence of one of these codes means that your app successfully connected to a web server and executed an HTTP request.

 

However, there are other conditions where your app cannot execute an HTTP request. It could be you're connecting to a server that doesn't have a web server running on the port you're connecting to (80 for HTTP, 443 for HTTPS, or user-specified), or there is a web server, but it's hung up and not responding, or the server could be down, or there is a networking problem preventing you from reaching the server. All of these conditions, the .isError parameter should be true, and the .status value is irrelevant. I would treat a -1 as the value when .isError is true since we couldn't complete a valid HTTP request.

 

Rob



[TOPIC: post.html]
#4

akao

[GLOBAL: userInfoPane.html]
akao
  • Contributor

  • 342 posts
  • Corona SDK

Thank you so much for the clarification Rob! By testing for .isError, we are now handling things correctly. thx.




[topic_controls]
[/topic_controls]