我已经在我的项目中尝试过Socketio库但无法建立连接,我还想发送mattermost服务器的身份验证头来检查连接是否成功。任何人都可以提出任何解决方案来解决这个问题吗?请参考我使用的以下代码和错误日志。
let manager = SocketManager(socketURL: URL(string: "******")!,config: [.log(true), .compress, .connectParams([JSON DATA])
}
let namespaceSocket = self.manager.socket(forNamespace: "/****")
self.addHandlers(socket: namespaceSocket)
namespaceSocket.connect()
namespaceSocket.on(clientEvent: .connect) {data, ack in
print("socket connected")
}
namespaceSocket.on(clientEvent: .error) {data, ack in
print("socket not connected")
}
/*****错误*******/
**** LOG SocketIOClient{****}: Adding handler for event: connect
**** LOG SocketIOClient{****}: Adding handler for event: error
**** LOG SocketIOClient{****}: Handling event: statusChange with data: [connecting]
**** LOG SocketIOClient{****}: Joining namespace /****
**** LOG SocketManager: Tried connecting socket when engine isn't open. Connecting
**** LOG SocketManager: Adding engine
**** LOG SocketEngine: Starting engine. Server: ****
**** LOG SocketEngine: Handshaking
**** LOG SocketEnginePolling: Doing polling GET ****
**** LOG SocketIOClient{/***}: Handling event: error with data: ["Tried emitting when not connected"]