Romuald Romuald - 4 years ago 212
iOS Question

Connect with an iOS swift app

I'm trying to connect a simple iOS app to a sails.js API. The iOS app is written in swift. The version of sails is the 0.11

For the web-socket management I use

class Communicate: UIViewController {

let socket = SocketIOClient(socketURL: "localhost:2000")

override func viewDidLoad() {

func addHandlers() {

socket.on("connect") {data, ack in
print("socket connected !") // This is working

self.socket.emit("get", ["url": "/device"]) // I get the sails error


On the sails.js console, I get the following error:

verbose: Receiving incoming message from { url: '/device?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=iOS&__sails_io_sdk_language=fr' }

error: Error (SAILS:HOOK:SOCKETS:PARSE_VIRTUAL_REQ):: Failed to parse incoming request.

details: 'Sails v0.11.x is not compatible with the client SDK version you are using (0.9.0). Please see the v0.11 migration guide on for more information.' }

I probably do something wrong to imitate the behaviour of, but I don't know how to achieve it.

Thank by advance for your help.

Answer Source

Instead of changing the server, you can connect parameters to tell the server that you comply with v0.11.0 semantics with:

self.socket = SocketIOClient(socketURL: baseWebSocketServerURL, options: 

I think that this is a better solution than hacking the server and breaking semantic version checking for other clients.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download