square/SocketRocket — Issue #7: didConnect: message sent to deallocated instance
Author: baberone
Created: 2012-02-15 22:16:18+00:00
State: open

Hi,

I've implemented your SRWebSocket in a IOS 5 application. I fixed a problem I had:

in didConnect (SRWebSocket.m):
2012-02-15 22:33:09.361 SC[11526:707] *** -[NSURLRequest release]: message sent to deallocated instance 0x157c30

just at

CFHTTPMessageRef request = CFHTTPMessageCreateRequest(NULL, CFSTR("GET"), (__bridge CFURLRef)_url, kCFHTTPVersion1_1);

This is my initialization code:

NSURLRequest *request = [[NSURLRequest requestWithURL:[NSURL URLWithString:@"ws://dedi.adiict.be:99999/echo"]] retain];
_webSocket = [[SRWebSocket alloc] initWithURLRequest:request];
_webSocket.delegate = self;
[_webSocket open];

See the 'retain' added when initializing the request; without it I get that error stated above. When added, everything runs smoothly...

I also noticed that

[_webSocket closeWithCode:-1 reason:@"Ok"];

doesn't seems to do anything (well I never get the delegate method called after that - nor does the 'close' method).

And when running the memory leak analyzer tool from XCode I see a bunch of potential leaks.I'll try to do some profiling to see if there really are leaks. I'm feeling like a n00b when I see some of your code...

Keep up the good work !!