Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-connecting a disconnected socket #11

Closed
lukeredpath opened this issue Feb 17, 2012 · 2 comments
Closed

Re-connecting a disconnected socket #11

lukeredpath opened this issue Feb 17, 2012 · 2 comments

Comments

@lukeredpath
Copy link
Contributor

In my library, I have a connection object that wraps an SRWebSocket object.

When my app loses network activity and causes a disconnection, this bubbles up using delegation and I encourage people to use Reachability at this stage to check for network availability and if necessary, wait until it becomes available before reconnecting.

What I'm finding though, is that if the web socket disconnects due to a network error (to test, I'm simply pulling out my ethernet cable), I'm unable to re-use it. Calling open on it again doesn't appear to do anything. What I end up doing is creating a brand new socket instead.

Is this expected behaviour?

@lukeredpath
Copy link
Contributor Author

@mikelikespie
Copy link
Contributor

Hi Luke,

You observations are correct.

I'm modeling it after the semantics defined for browser agents:
http://dev.w3.org/html5/websockets

So creating a new SRWebSocket object is the correct thing to do.

Similar to how you don't re-use an NSStream object after it gets
disconnected, you don't reuse a websocket.

I do agree that it probably needs to be clarified a bit (and possibly some
asserts added).

-Mike

Michael Lewis
lolrus.org
mikelikespie@gmail.com

On Fri, Feb 17, 2012 at 10:38 AM, Luke Redpath <
reply@reply.github.com

wrote:

In my library, I have a connection object that wraps an SRWebSocket object.

When my app loses network activity and causes a disconnection, this
bubbles up using delegation and I encourage people to use Reachability at
this stage to check for network availability and if necessary, wait until
it becomes available before reconnecting.

What I'm finding though, is that if the web socket disconnects due to a
network error (to test, I'm simply pulling out my ethernet cable), I'm
unable to re-use it. Calling open on it again doesn't appear to do
anything. What I end up doing is creating a brand new socket instead.

Is this expected behaviour?


Reply to this email directly or view it on GitHub:
#11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants