I have a socket.io server running on Node.js listening on localhost:3000. I then try to connect to that server with a swift mac app. Here's how I'm doing the connection in swift
let manager = SocketManager(socketURL: URL(string: "https://localhost:3000/")!, config: [.secure(true), .log(true), .compress])
let socket: SocketIOClient
init() {
socket = manager.defaultSocket
print(storage)
addHandlers()
socket.connect()
}
The above code is inside a struct which is created as a property value in a ContentView so I don't think my manager is being destroyed.
Here are the relevant logs
2022-12-20 17:05:48.742 MultiSnake[46501:971261] LOG SocketIOClient{/}: Handling event: statusChange with data: [connecting, 2]
2022-12-20 17:05:48.742 MultiSnake[46501:971261] LOG SocketIOClient{/}: Joining namespace /
2022-12-20 17:05:48.742 MultiSnake[46501:971261] LOG SocketManager: Tried connecting socket when engine isn't open. Connecting
2022-12-20 17:05:48.742 MultiSnake[46501:971261] LOG SocketManager: Adding engine
2022-12-20 17:05:48.743 MultiSnake[46501:971274] LOG SocketEngine: Starting engine. Server: https://localhost:3000/
2022-12-20 17:05:48.743 MultiSnake[46501:971274] LOG SocketEngine: Handshaking
2022-12-20 17:05:48.745 MultiSnake[46501:971274] LOG SocketEnginePolling: Doing polling GET https://localhost:3000/socket.io/?transport=polling&b64=1&EIO=4
2022-12-20 17:05:48.857 MultiSnake[46501:971288] ERROR SocketEnginePolling: A server with the specified hostname could not be found.
2022-12-20 17:05:48.857 MultiSnake[46501:971288] ERROR SocketEngine: A server with the specified hostname could not be found.
2022-12-20 17:05:48.871 MultiSnake[46501:971261] ERROR SocketManager: A server with the specified hostname could not be found.
2022-12-20 17:05:48.871 MultiSnake[46501:971261] LOG SocketIOClient{/}: Handling event: error with data: ["A server with the specified hostname could not be found."]
2022-12-20 17:05:48.872 MultiSnake[46501:971261] LOG SocketManager: Starting reconnect
I can connect to localhost:3000 from the browser and I have done the required Certficate Authority related things for HTTPS to work. I have not made an ATS exception in my mac app and I would prefer not to.
I have tried to change the "https://localhost:3000/" string to "localhost:3000/" and add .secure(true) to the manager's config but then socket.io would poll https:/socket.io instead of the right url. I don't know where I can specify the hostname and I think I have followed the examples here.