Kla*_*ker 5 sockets xcode ios socket.io swift
我正在尝试连接到 Xcode 服务器的内部 socket.io。我使用以下方法初始化客户端:
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)])
Run Code Online (Sandbox Code Playgroud)
但是当我使用时self.socket.connect()我得到这样的响应:
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."
)
Run Code Online (Sandbox Code Playgroud)
socket.io.js我尝试更改文件的路径,xcode/internal/socket.io/1/但它都给出相同的响应,而是Welcome to socket.io被那里的文件内容替换。
小智 9
Socket.IO-Client-Swift (16.0.1):版本,需要添加:.forceWebsockets(true)。
例子:
let manager = SocketManager(socketURL: URL(string: "http://localhost:8080")!, config: [.compress, .forceWebsockets(true)])
let socket = manager.defaultSocket
Run Code Online (Sandbox Code Playgroud)
https://github.com/socketio/socket.io-swift-fiddle/blob/main/Sources/Fiddle/main.swift
尝试将其ws作为协议,如下所示:
... NSURL(string: "ws://37.203.216.82") ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2839 次 |
| 最近记录: |