-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash NSStream #4
Comments
what are you passing in for your url? Needs to be in a the standard host + port configuration. P.S. Might want to wrap your error in a code block, makes it easier to read. |
Test Xcode 6 Betta 5 This my code: class Server: NSObject, WebsocketDelegate {
var socket : Websocket!
func initServerConnect() {
socket = Websocket(url: NSURL.URLWithString("ws://193.169.240.21:9000"))
socket.delegate = self
socket.connect()
}
//websocket delegate methods
func websocketDidConnect() {
println("websocket is connected")
}
func websocketDidDisconnect(error: NSError?) {
println("websocket is disconnected: \(error!.localizedDescription)")
}
func websocketDidWriteError(error: NSError?) {
println("wez got an error from the websocket: \(error!.localizedDescription)")
}
func websocketDidReceiveMessage(text: String) {
println("got some text: \(text)")
}
func websocketDidReceiveData(data: NSData) {
println("got some data: \(data.length)")
//self.socket.writeData(data) //example on how to write binary data to the socket
}
} All error message
Thanks. |
Alright code looks fine. What is the websocket server you are trying to connect to? Did you try using the example ruby websocket server in the examples folder? I bet the issue is with the websocket server, as in my testing starscream connected fine to any server that passed autobahn tests. |
This custom server, if i use SoketRecket(ObjC) all ok. But if i use this class error (( |
Alright, good to know. I am not sure what to do at this point, as my several test servers work fine and I don't have a way to reproduce the issue. If you know of a websockets server that can be used to reproduced the issue, I would be happy to track it down. |
I had the same problem; getStreamsToHostWithName is not found on mavericks. I replaced line 154 with
to run in MacOS X 10.9 |
@vikingjs good point and thank you, I didn't consider it was being run on 10.9. It was only designed to work on 10.10 and iOS 8 as I figured Swift was going to be primarily done with new projects going forward. That being said we could probably support older OSes by simply doing a API check before doing the bind or just use the CoreFoundation calls if there is interest. |
Probably don't even need an API check for that one; I think NSStream::getStreamsToHost() is universal, and has been there since OSX 10.3. I haven't specifically checked for it in iOS, however. |
True true, doesn't appear to be in iOS though: I would prefer if possible not to have to do a iOS/OS X check. Main reason I was drawn to the |
I looked at NSStream.h where it extends getStreamsToHostWithName() and it also has getStreamsToHost(). It's probably a bug in the header that it doesn't check the environment, which is why this problem was so mysterious. The compiler had no problem with the new method call. So your reasoning about Swift is parallel to Apple's - they also see Swift as a forward-only tool. Unfortunately, I'm not in that happy world yet. At any rate, I think it would be worth testing to see if the older method still works. I'd even bet the new one calls it :). |
Look at the source of instead the documentation, what!?!?! 😄. I just end up using the coreFoundation API as I had already done it in my Objective-C version of this library and I know it works on both platforms. Any questions let me know. |
This version works fine for me. Thanks! |
This version works fine for me to. Thanks! |
Glad to hear it! |
This is a great succinct piece of code. I had no trouble connecting to some test sites. I successfully connected to our server but when I sent a login string, using writeString(), our server developer said the string I sent was broken into 10 byte pieces. I have used socket.io with javascript and had no problems connecting or sending the same string. Any suggestions? |
*writeText() not writeString, sorry. |
oops, commentary closed, too bad :( |
@frankgeonet Glad to hear you like the code! If you found a bug, please open an new issue so we can start dialog on it, as this issue has been resolved. Thanks! |
Error if i uses this class
Log:
2014-08-13 22:02:46.079 WebSocket[2937:1803] +[NSStream getStreamsToHostWithName:port:inputStream:outputStream:]: unrecognized selector sent to class 0x3853e86c
2014-08-13 22:02:46.083 WebSocket[2937:1803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSStream getStreamsToHostWithName:port:inputStream:outputStream:]: unrecognized selector sent to class 0x3853e86c'
The text was updated successfully, but these errors were encountered: