undefined error with simple example

2 views
Skip to first unread message

morgler

unread,
Sep 5, 2011, 6:08:19 AM9/5/11
to unitt-project
Hi,

I can't seem to connect to the ws://echo.websocket.org web socket with
unitt through the iPhone simulator. Basically I created a simple
iPhone app and used all the example code from
http://code.google.com/p/unitt/wiki/UnittWebSocketClient. However,
when I try to connect to a web socket (e.g. ws://echo.websocket.org or
my localhost:8080), the library calls back my didReceiveError method
with aError being null. This all happens in the simulator with iOS 5.
Any ideas?

Cheers,

Matthias

Josh Morris

unread,
Sep 6, 2011, 12:19:15 AM9/6/11
to unitt-project
I have not tried it against iOS5, but when I run the following code I
get a specific error. I have included my code snippets below. I think
the root of the problem is that the server running on websocket.org is
many revisions out of date. It looks to be hixie75/75ish. The spec is
now up to hybi-rev12 I think. What version of the specification is
your server running on localhost? You want to make sure you use the
right client version for the right server version.

//logic to connect
//------------------------------------------
ws = [[WebSocket07 webSocketWithURLString:@"ws://
echo.websocket.org" delegate:self origin:@"http://websocket.org"
protocols:nil tlsSettings:nil verifyHandshake:YES] retain];
[ws.open];
//------------------------------------------

//web socket delegate error method
//------------------------------------------
- (void) didReceiveError: (NSError*) aError
{
NSLog(@"Error: %@", [aError localizedDescription]);
}
//------------------------------------------

The output in my console is...
Error: The operation couldn’t be completed. Connection refused


Josh


On Sep 5, 4:08 am, morgler <morg...@googlemail.com> wrote:
> Hi,
>
> I can't seem to connect to the ws://echo.websocket.org web socket with
> unitt through the iPhone simulator. Basically I created a simple
> iPhone app and used all the example code fromhttp://code.google.com/p/unitt/wiki/UnittWebSocketClient. However,

Josh Morris

unread,
Sep 6, 2011, 12:23:37 AM9/6/11
to unitt-project
Oops. I was running the wrong test. I do not get an error from
AsyncSocket code either. Regardless, the problem still appears to be
the version differences. What version of the specification are you
running on your localhost?


Josh

morgler

unread,
Sep 6, 2011, 11:28:38 AM9/6/11
to unitt-project
Im afraid I'm fairly unexperienced when it comes to web sockets :(. So
locally I'm actually running a juggernaut 2 server (https://github.com/
maccman/juggernaut) on http://localhost:8080. Juggernaut should be
nothing but a thin layer on top of web sockets, but I don't know how
it would impact the possibility to connect to the web socket directly.
My production machine would have the same juggernaut as the server
part (only behind SSL).

Matthias

Josh Morris

unread,
Sep 6, 2011, 1:19:08 PM9/6/11
to unitt-project
Juggernaut uses an older version of the socket.io and Node libraries
that conforms to a very early release of the web socket specification.
The specification is still not finalized, so technically nothing is
"truly" web socket compliant yet. However, the early releases are not
compatible with the current specification so early servers and clients
will not work at all with the current version. Jetty has a more recent
implementation of web sockets if you want a Java server, if not, you
can still use a Node server, but use the https://github.com/asutherland/WebSocket-Node
library. It has a rev07 implementation that looks fairly complete.


Josh

On Sep 6, 9:28 am, morgler <morg...@googlemail.com> wrote:
> Im afraid I'm fairly unexperienced when it comes to web sockets :(. So
> locally I'm actually running a juggernaut 2 server (https://github.com/
> maccman/juggernaut) onhttp://localhost:8080. Juggernaut should be

Josh Morris

unread,
Sep 12, 2011, 10:59:21 AM9/12/11
to unitt-project
You can try the Rev00 version (WebSocket00) and I believe that works
with the Hixie75/76 servers. Just make sure to turn "verifyHandshake"
to NO. Regardless, that version is still outdated and you will want to
move to a more recent one at your earliest convenience.

On Sep 6, 11:19 am, Josh Morris <joshuadmor...@gmail.com> wrote:
> Juggernaut uses an older version of the socket.io and Node libraries
> that conforms to a very early release of the web socket specification.
> The specification is still not finalized, so technically nothing is
> "truly" web socket compliant yet. However, the early releases are not
> compatible with the current specification so early servers and clients
> will not work at all with the current version. Jetty has a more recent
> implementation of web sockets if you want a Java server, if not, you
> can still use a Node server, but use thehttps://github.com/asutherland/WebSocket-Node

Josh Morris

unread,
Oct 2, 2011, 5:11:54 PM10/2/11
to unitt-project
I have updated the WebSocket00.h to work with the ws://echo.websocket.org
service described in your original post. It is in the trunk. I will be
releasing a new version of the library in the next day or so once I
validate other functionality. Please try again and let me know. :)
Reply all
Reply to author
Forward
0 new messages