swifter icon indicating copy to clipboard operation
swifter copied to clipboard

Issue with WebSocket

Open Joebayld opened this issue 8 years ago • 2 comments

Anyone having issues connecting to the web socket? When I try to connect from a browser, the browser gives me an error 404 that it cannot connect.

Anything I could possibly be missing?

Thanks

Joebayld avatar Jan 05 '18 23:01 Joebayld

Found part of the problem. If I have a wildcard url, it overrides the websocket. Perhaps there should be a check for existing paths before using the /: wildcard?

Example below:

        let subdir = Bundle.main.resourceURL!.appendingPathComponent("Public")
        server["/:"] = shareFilesFromDirectory(subdir.path)
        // The line above causes the web socket to not work...

        server["/websocket-echo"] = websocket({ (session, text) in
            session.writeText(text)
        }, { (session, binary) in
            session.writeBinary(binary)
        }) 

Joebayld avatar Jan 21 '18 08:01 Joebayld

The bindResult value is not changing and it is showing -1. The problem which I think is mostly because of app settings. Can anyone suggest me what to do?

bindResult = withUnsafePointer(to: &addr) { bind(socketFileDescriptor, UnsafePointer(OpaquePointer($0)), socklen_t(MemoryLayout<sockaddr_in6>.size)) }

This is the error which it shows to me. SocketError

bindFailed : "Operation not permitted"

SocketError.bindFailed("Operation not permitted")

Do you have solution for this?

srijanraj avatar Apr 06 '18 05:04 srijanraj