I am getting
The operation couldn’t be completed. No such file or directory
this is my connection line
.... SocketIOClient(socketURL: "192.168.1.2:XXXX", opts: ["connectParams" : ["token": (authToken ?? " ")] ])
iOS 8 is working ok.
I'm having trouble reproducing.
One thing I did run into when testing on iOS 9 is that it requires SSL, unless you specify as thing in the info.plist.
I have specified to bypass it so far.
btw I am using swift 2 beta 5
Can you create a small project that reproduces the problem? Also include the server.
Hi @nuclearace I just decided to move to pusher because my client couldn't wait for this.
I don't have much time TBH but I will try to help you out here.
Server
var io = require("socket.io")(3001)
var socketioJwt = require("socketio-jwt")
io.use(socketioJwt.authorize({
secret: "XXXXX",
handshake: true
}))
iOS
import Foundation
public class STMeetingWebsockets: NSObject {
let socket: SocketIOClient = {
var error: NSError?
let authToken = "XXXX"
return SocketIOClient(socketURL: XXXXX, opts: ["connectParams" : ["token": (authToken ?? " ")] ])
}()
@objc public func startOnConnect(onConnect: ((socket: SocketIOClient?) -> Void)?, onError: (Void -> Void)?) {
self.socket.on("connect") { data, ack in
print("Socket.io connected 👌")
if let connectCallback = onConnect{
connectCallback(socket: self.socket)
}
}
self.socket.on("error") { error in
print("Socket.io error âť—âť—âť—", error)
if let errorCallback = onError{
errorCallback()
}
}
socket.connect()
}
On iOS9 now and having the same issue. Was there a fix for this?
I've never been able to reproduce this. I assume it's something to do with how the server is set up
Odd, I'm just playing around with it now. Admittedly I'm using Flask-SocketIO but I run it on an iOS 8 simulator and it works perfectly, swap to the iOS 9 simulator and get the error.
Hm, I know that there was a case where the flask implementation of socket.io had an issue with the client because the author of the implementation didn't know you could connect directly to with websockets.
Yeah thats been resolved now in the v1.0 alpha/beta release. Works with either upgrading from polling to websockets, or just direct websockets. I'm going to step through it now and see if I can see where it fails. The server seems to think the connection is accepted, but the client just keeps retrying with that error.
Has the client been tested to work with iOS 9 and Swift 2.0 with a node server?
Yes, it works fine on a basic node server
disconnectStream(...) is called in the delegate for the stream methods in WebSocket.swift:
public func stream(aStream: NSStream, handleEvent eventCode: NSStreamEvent) {
...
The value of aStream.streamError in here is:
Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"
However, potentially an issue with the iOS 9 simulator. Weirdly it works fine on iOS 9 on an actual device, just not the simulator. Also, seems to be reports of people having the same error above (for different applications/frameworks) on iOS 9 with just the simulator. Some have even said that the error began occurring only after updating from Yosemite to El Capitan.
Saw a similar issue you had responded to earlier @nuclearace and it was something to do with the host value. I just tried playing with the host ip value of the server with the following results:
host='0.0.0.0'
host='192.168.1.14' - my actual LAN ip
host='127.0.0.1'
So... not really sure what is going on / what the issue is. These results combined with the findings in the post above leave me confused.
Edit: Here is the similar issue: https://github.com/socketio/socket.io-client-swift/issues/182
So it sounds like it could be a problem with the simulator?
That would explain why I wasn't able to reproduce it, since I do all my testing using OS X
Either the simulator or El Capitan. Seems like it's one of the two. Since others have reported the issue only happening after updating from Yosemite to El Capitan, I'de possibly say something related to the underlying networking in El Capitan? No idea what though.
But I guess a workaround is to make sure the servers host ip value is '127.0.0.1' when using the simulator. This seems to work.
Then change that to '0.0.0.0' or whatever other value you require when testing on devices.
i'm having the same issue, on Yosemite was working perfect on IOS8 and IOS9 with the same code, after upgrade to El Capitan, it only works locally if the server is 127.0.0.1 if i set my mac's ip it doesn't connect.
Contrary to my previous post, you can set the servers IP to 0.0.0.0 but the simulator must still connect to 127.0.0.1.
A little work around I am using at the moment is:
0.0.0.0.
#if (arch(i386) || arch(x86_64)) && os(iOS)
static let serverURL = "http://127.0.0.1:PORT" // for simulator
#else
static let serverURL = "http://MACHINES_LOCAL_IP:PORT" // for local devices
#endif
Most helpful comment
Contrary to my previous post, you can set the servers IP to
0.0.0.0but the simulator must still connect to127.0.0.1.A little work around I am using at the moment is:
0.0.0.0.#if (arch(i386) || arch(x86_64)) && os(iOS) static let serverURL = "http://127.0.0.1:PORT" // for simulator #else static let serverURL = "http://MACHINES_LOCAL_IP:PORT" // for local devices #endif