Reputation: 131
I'm trying to connect to my Xcode Server's internal socket.io. I initialize the client using this:
self.socket = SocketIOClient(socketURL: NSURL(string: "https://37.203.216.82")!, options: [.Path("/xcode/internal/socket.io"), .Log(true), .Reconnects(true), .ForceNew(true), .SessionDelegate(self), .SelfSigned(true)])
But when I use self.socket.connect()
I get this response:
2016-07-15 16:13:49.179 MyApp[84260:1941316] LOG SocketIOClient: Adding handler for event: connect
2016-07-15 16:13:49.180 MyApp[84260:1941316] LOG SocketIOClient: Adding handler for event: integrationStatus
2016-07-15 16:13:49.180 MyApp[84260:1941316] LOG SocketIOClient: Adding handler for event: advisoryIntegrationStatus
2016-07-15 16:13:49.180 MyApp[84260:1941316] LOG SocketIOClient: Adding engine
2016-07-15 16:13:49.181 MyApp[84260:1941316] LOG SocketEngine: Starting engine. Server: https://37.203.216.82
2016-07-15 16:13:49.181 MyApp[84260:1941316] LOG SocketEngine: Handshaking
2016-07-15 16:13:49.182 MyApp[84260:1941792] LOG SocketEnginePolling: Doing polling request
2016-07-15 16:13:49.317 MyApp[84260:1941792] LOG SocketEnginePolling: Got polling response
2016-07-15 16:13:49.322 MyApp[84260:1941786] LOG SocketEngine: Got message: Welcome to socket.io.
2016-07-15 16:13:49.324 MyApp[84260:1941786] ERROR SocketIOClient: Got unknown error from server Welcome to socket.io.
2016-07-15 16:13:49.326 MyApp[84260:1941786] LOG SocketIOClient: Handling event: error with data: (
"Got unknown error from server Welcome to socket.io."
)
I've tried changing the path to the socket.io.js
file or xcode/internal/socket.io/1/
but it all gives the same response, instead, Welcome to socket.io
is replaced by the contents of the file there.
Upvotes: 5
Views: 3093
Reputation: 91
Socket.IO-Client-Swift (16.0.1): version, need to add: .forceWebsockets(true)
.
Example:
let manager = SocketManager(socketURL: URL(string: "http://localhost:8080")!, config: [.compress, .forceWebsockets(true)])
let socket = manager.defaultSocket
https://github.com/socketio/socket.io-swift-fiddle/blob/main/Sources/Fiddle/main.swift
Upvotes: 9
Reputation: 545
I have updated swift client framework to the latest 16.0.1
version. But this error happened. There is an open issue also: https://github.com/socketio/socket.io-client-swift/issues/1355
I have fixed this by reverting to the old stable version:
pod 'Socket.IO-Client-Swift', '~> 15.2.0'
Upvotes: 1
Reputation: 338
Check socket.io version on both server and client side, mismatch of both may be cause of this error
Upvotes: 1
Reputation: 41905
Try putting ws
as the protocol, like this:
... NSURL(string: "ws://37.203.216.82") ...
Upvotes: 0