Hi, I'm trying to setup a simple websocket connection from the project game template. Using NWWebSocket 0.5.4 or urlSession.webSocketTask on the client and Vapor on the server.
Haven't been able to connect since macOS ~14-15 with the same Xcode settings.
I can send HTTP routes but the websocket itself does not connect. The closest I've got is connect but then immediate disconnect. I know the websocket works with CLI.
Have plist allowing arbitrary loads and local networking. Also App Sandbox with network boxes checked in Debug mode.
The error I get is:
Error receiving: Error Domain=NSURLErrorDomain Code=-1011 "There was a bad response from the server." UserInfo={NSErrorFailingURLStringKey=http://localhost:8090/echo, NSErrorFailingURLKey=http://localhost:8090/echo, _NSURLErrorWebSocketHandshakeFailureReasonKey=5, NSLocalizedDescription=There was a bad response from the server.} Failed to send message: Error Domain=NSURLErrorDomain Code=-1011 "There was a bad response from the server."
Thanks.
Error -1011 is NSURLErrorBadServerResponse
, which strongly suggests that the server sent a response that the client didn’t like. I recommend that you use a packet trace to see what’s happening on the ‘wire’.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"