Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Socket connection lost after Sleep
Started by hegoro1 Mar 08 2012 04:13 AM

- - - - -
3 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

hegoro1

[GLOBAL: userInfoPane.html]
hegoro1
  • Observer

  • 16 posts
  • Corona SDK

hi Guys. I'm having a hard time with this. Hopefully someone could help me. I have an application that creates a socket just beginning to send messages to my server. I added "UIApplicationExitsOnSuspend = false" to the build.settings file. When the user presses the "home" button I receive fine the applicationSuspend and applicationResume events and the socket is still alive. But when the phone goes to sleep or user presses Sleep/Wake button, both events are fired fine and also the socket get closed.

More info: if I test this on iphone 3gs it works, but in iphone 4 or 4s doesn't. I'm really sure this was working before (2 weeks ago), So I'm going nuts now.

Thanks for any help
uid: 103124 topic_id: 23022 reply_id: 323022


[TOPIC: post.html]
#2

peach pellen

[GLOBAL: userInfoPane.html]
peach pellen
  • Corona Geek

  • 8,866 posts
  • Alumni

Hi Hegoro,

I asked another member of the team with a little more experience than myself and he advised me that the socket would likely always close when the device went to sleep and that you'd need to check the connection and re-open the socket after an applicationResume event. (Especially as the user might have changed locations in that time and no longer have access to the same wifi, etc.) Best practice would be to always check connection on resume.

He also had some thoughts on difference between devices;

"He says that it works on an iPhone3gs but not iPhone4. Are they both running the same OS? Since he is a trial user, he must be using the same build (704) and nothing would have changed there.

If he is working with "sockets," he is running LuaSockets which is open source code, which we don't alter. I don't believe Corona does anything different between a "home" button suspend and going to sleep so that would be an OS/device issue."


I hope this is useful for you. Out of interest are you indeed running the same OS?

Peach :)
uid: 52491 topic_id: 23022 reply_id: 92209


[TOPIC: post.html]
#3

hegoro1

[GLOBAL: userInfoPane.html]
hegoro1
  • Observer

  • 16 posts
  • Corona SDK

hi Peach
Thanks for your response and advice. I'll check the connection in the applicationResume event and create a new socket.

I'm performing my test with these devices:
iPhone 3gs (iOS version 4.2.1)
iPhone 4s (iOS version 5.0.1 (9A405))
The weird thing is I'm sure this was working fine 2 weeks ago. Well, LuaSockets and same build(704) for both.
I have a subscriber account but when I tried to compile (build 761-751-741) my app and tested it, the facebook.login didn't work properly. I have to check it. Also, I can't create or reply posts with that account although I have not spent a lot of time trying to figure out the reason.

Thanks again

uid: 103124 topic_id: 23022 reply_id: 92214


[TOPIC: post.html]
#4

peach pellen

[GLOBAL: userInfoPane.html]
peach pellen
  • Corona Geek

  • 8,866 posts
  • Alumni

Hey hegoro,

The posting issue I can assist with to an extent - sometimes people don't activate their accounts for posting. This is normally because the automated email goes to spam.

Use this form: http://developer.anscamobile.com/forms/support

Say you have a Pro account but can't post on the forum, can we please assist - and then someone will be able to set that up for you. (It may take a day or two as it's Friday night now but it will get done.)

Peach :)
uid: 52491 topic_id: 23022 reply_id: 92328



[topic_controls]
[/topic_controls]