Closed ghost closed 10 years ago
Without seeing the code, I'm not sure what answers I can provide you. If I I were in your shoes here are some things I would look at. First according to your last comment on the other issue are you using a Socket.IO server? I'm far from a Socket.IO expert, but from looking at their docs it appears they do use websockets as a transport, but there seems to be a bit more involved with their setup then a simple RFC 6455 websocket library, hence why there has been Socket.IO specific libs developed to handle these idiosyncrasies. Another thing I would check is fragmentation settings. According to the RFC, this is generally controlled on the server to handle the max frame size. Also is there an open source websocket you are working with?
Thank you for your response. I suspect it is indeed a problem with our server code so I will look into that. I am fairly certain the problem does not originate with your code so I will close this case.
acmacalister you were absolutely correct! The problem was the receive buffer size in our server implementation. It works like a charm now. Thanks again.
I have modified your sample to connect to our server and send a login string.
The websocket successfully connects to our server:
var socket = Websocket(url: NSURL(scheme: "ws", host: "ourhost_url:8080", path: "/")!, protocols: ["our_protocol"]) . . . socket.connect() . . . Once connected, our server expects a json string which I send like this: . . . let myConnect = "{'cmd':'connect','target':'@2.1.1.1','params':{'password':'my_password','mode':'my_mode'}}" socket.writeString(myConnect) . . . The server receives this string but it is broken into 10 byte substrings. The server expects a single string so returns a failure message which the websocket successfully receives.
I looked at the websocket code and couldn't see where this "parsing" into 10 byte strings could be taking place. Could this be happening while buffers are being created in dequeueWrite()?
I suspect this is not a bug and there is likely something I am missing, especially as I am new to iOS development. Any suggestions will be appreciated.
Thanks