zaphoyd / websocketpp

C++ websocket client/server library
http://www.zaphoyd.com/websocketpp
Other
6.98k stars 1.97k forks source link

iPad/iPhone can't connect with latest version #195

Closed spyang closed 11 years ago

spyang commented 11 years ago

Hi, when I first started developing using websocketpp, I used this version: zaphoyd-websocketpp-16aaa00.zip (August 15, 2012)

A couple days ago, I upgraded to use websocket-experimental.zip (3/19/2013).

In the past, my iPad 1 was able to connect to my websocket server succesfully. Now it can't. I am also able to reproduce this issue with an iPhone using both iOS5 and iOS6.

Is there any setting I can tweak with the latest websocketpp code to enable my iPad to connect?

zaphoyd commented 11 years ago

iOS 5 uses an older, insecure, draft version of the WebSocket Protocol. 0.3.x, the "experimental" branch presently does not support that one. Support for iOS 5 will be re-added to 0.3.x before it is promoted to master, though it should be noted that clients using this protocol will only ever work in a degraded feature state since that version of the protocol lacks many features of the final one.

iOS 6+ should work with 0.3.x right now though. I'll do some more testing.

spyang commented 11 years ago

Thank you for the quick explanation of the problem :-)

spyang commented 11 years ago

As an update, you might want to know that I have reverted to the 0.2.x branch. It turns out that many of the older browsers are incompatible with the 0.3.x branch, so supporting the draft version of the Websocket Protocol truly is required for anybody to seriously adopt 0.3.x for commercial use. At a customer's site using 3-year-old Macs, none of the browsers were compatible with my code that used 0.3.x, but after I reverted to 0.2.x, those computers were then compatible.

zaphoyd commented 11 years ago

Yes, 0.3.x won't work with iOS 5 and safari 5 at this time. Draft 76 support for 0.3.x will probably show up in the nest week or two. I have handshakes completely done (the hard part) and just need to finish testing the framing.

zaphoyd commented 11 years ago

I've pushed hybi00 (Draft 76) support for 0.3.x. I've tested it with iOS 5 and FireFox 4 and it seems to work. I tried running chrome 11, but it crashes on all the machines I have access to. I also don't have easy access to Safari 5 at the moment either. In theory they should all behave similarly. I'll try and find some more hybi00 browsers to test with, but in the meantime if anyone else is able to find any issues let me know.

zaphoyd commented 11 years ago

Opera 11.64, another hybi00 browser, works.

spyang commented 11 years ago

OK, I will download 0.3.x today and start testing it soon.

zaphoyd commented 11 years ago

I was able to get ahold of a copy of Safari 5 for Mac and confirmed that it works with 0.3.x as well, at least for basic stuff.

spyang commented 11 years ago

I have switched back to 0.3.x to test things out. Older browsers are able to successfully connect. However, I have a new problem.

With Chrome 12.0.742.124 (from the year 2011), I have a problem with this call:

boost::system::error_code code; mServer.close(user->mHandle, websocketpp::close::status::going_away,"",code);

I make this call happen on the server side when my client sends a "logOut" message. For some reason, it doesn't close the socket at all, so my session stays alive and my client can continue to interact with my server. On the same client computer, I have Firefox 16.0.2, and it closes the socket just fine.

I don't yet know how many browsers will have this problem, but this is an issue for me. I could of course modify my client-side code to terminate the connection after getting an acknowledgment of logout from the server, but I much prefer for the server to terminate the connection. Furthermore, this is an issue if my server code wants to boot a user that has been idle for too long. I did not have this issue using the 0.2.x branch. A symptom you might care to know is that while using the 0.2.x branch, there appears to be a delay of a few seconds before the socket gets closed when using this version of Chrome, but at least it gets closed.

spyang commented 11 years ago

FYI, ./processors/hybi00.hpp has a cout line which you probably meant to comment out. My program keeps printing out "state: 2" whenever I use an older browser, such as when I connect with my iPhone 4.

zaphoyd commented 11 years ago

i've corrected the cout statement and implemented the hybi00 draft closing handshake. Keep in mind that the hixie76/hybi00 spec as implimented in old safari and chrome is really half baked. The close handshake is not supported everywhere and lacks the features that the final RFC 6455 handshake has.

At minimum now conforming hybi00 clients will be able to disconnect immediately. I tested this on FireFox 4 and iOS 5 and it seems to work.

zaphoyd commented 11 years ago

Haven't seen any iOS related issues recently so I am going to close this.