How to use SocketRocket with socket.io?

14,431

Solution 1

Well you socket.io has it's own protocol built on transport protocols such as websockets, or long polling, well SocketRocket is just a websocket library, no more. Socket.io also has some authentication, so it's not possible to use it, with normal web sockets. What I suggest you to use is a just websocket server, no more than that. Such as ws, which should compatible. There are other libraries, but, ws I believe is actively developed at the moment, and newer than others.

You can also make your clientside socket.io compatible, but I think its uneeded. Here's the specs for it: https://github.com/LearnBoost/socket.io-spec

Hope I helped.

Solution 2

socket.IO-objc on GitHub looks to be a mature Socket.IO / Objective C Library

It uses SocketRocket to handle the websocket connections.

This will allow you to have a socket server that supports older browsers (degrades to long-polling etc.) and is still accessable to your iOS app via SocketRocket.

Solution 3

I have just implemented an active socket connection between a Node.JS server, and an iOS application, using this library. I used this one because the README on Socket.IO-ObjC says

The current version of this library does not yet support socket.io v1.0. So if you want to use socket.io-objc, please fall back to v0.9.x.

but I always want to use the latest version for everything. So if you want to use Socket.IO v1.0, you can use the one on the link provided few line above.

Share:
14,431
seeker12
Author by

seeker12

Updated on June 18, 2022

Comments

  • seeker12
    seeker12 almost 2 years

    The new iOS websocket library, SocketRocket, looks really awesome, and the chat example project is really sweet. The example chat server is written in Python, of which I know none. I'm slightly familiar with socket.io on node.js and prefer to try javascript. I tried connecting the SocketRocket TestChat simulator app to the node.js(6.10) socket.io(0.8.7) but the connection was refused. (Also, I'm not a node expert either, so this may be a silly question).

    In a recent answer to an SO question, mikelikespie said to op: "I suggest updating your stack to use the iOS WebSocket library we just released."

    What does that mean exactly? What is necessary to get the SocketRocket library to talk to a node socket.io server? Any sample code or suggestions are greatly appreciated.

  • seeker12
    seeker12 about 12 years
    The ws library does seem like the way to go. I was unable to get a working implementation with ws, but that is a limitation of my javascript skills. I am marking this as answered because it makes sense and there are no other answers. Thanks.
  • Suz
    Suz over 9 years
    The link is to a library for earlier versions of Socket.IO. For a project that works with socket.io v 0.9+ and 1.0, try this one: socket.IO-objc