当前位置: 动力学知识库 > 问答 > 编程问答 >

"Got unknown error from server ..." using Socket.io on Swift

问题描述:

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.

网友答案:

Try putting ws as the protocol, like this:

... NSURL(string: "ws://37.203.216.82") ...
分享给朋友:
您可能感兴趣的文章:
随机阅读: