1

Im attempting to use websockets for a project. It needs to use the ipad, though i cant seem to make it work.

I have downloaded a copy of this code that uses phpwebsocket http://www.flynsarmy.com/2012/02/php-websocket-chat-application-2-0/ . Followed setting up the server. I got it working across computers, different browsers, no problem.

Then i wanted to test it on my ipad (ios 5.1) and it wouldnt work. So i made sure that websockets worked on ipad, which i found they did [link]http://websocket.org/echo.html .

I then looked at it further, to see it was attempting to connect, but then disconnecting after about 15 seconds, i assume timing out. It shows up in terminal on my mac, saying it has disconnected.

I am currently connecting my ipad to my mac over wifi to see if it was the router, and in terminal IP address shows differently, ending in 255.255.255.100 not 255.255.255.96

Does anyone have any ideas what is going on, or what i should do to sort it.

kanaka
  • 70,845
  • 23
  • 144
  • 140
mcclennon19
  • 623
  • 2
  • 6
  • 21
  • When I'm debugging stuff like this on windows machines I use Fiddler (http://www.fiddler2.com/fiddler2/). Is there anything like that you can use to see what request / response messages are being sent then post them up to help get a bit more info? – james lewis Mar 27 '12 at 22:11

1 Answers1

5

What a mess. On that page and in the project source, Flynsarmy indicates that he is using PHPWebSocket while in fact he is using php-websocket-server. (I have submitted a comment indicating the mistake on his page).

Those two PHP WebSocket projects are quite different:

  • PHPWebSocket is a relatively old and unmaintained project that only supports the older Hixie (prototype) version of the WebSocket protocol.
  • php-websocket-server is a newer but less well known project that only supports the newer HyBi/IETF (standard) version of the protocol.

Your problem is this: Safari Desktop and iOS currently supports the older Hixie version of the protocol which will not work with any project based on php-websocket-server.

It is fairly easy to make WebSocket servers that support both the old and new versions of the protocol (and most languages have implementations that do) since it the client/browser version can be detected from the initial handshake headers. However for some reason there is a lack of PHP based servers that support both.

kanaka
  • 70,845
  • 23
  • 144
  • 140
  • where did you find which protocol is currently supported by Safari Desktop and IOS? because, i think i'm running into the same problem here. my HTML5 application seems to work perfectly in google chrome, but not on Safari Desktop and IOS. i know the protocol on the websocket server side is the latest, the one "EVERYONE" agreed upon. If this is the same problem, i'm seriously pissed at Apple for not having implemented the latest (AND FINAL) protocol... – Michahell Jul 31 '12 at 13:17
  • I know because I've tested them as part of developing noVNC/websockify. If you can get the server to print the handshake you can tell from the handshake what specific version of the wire protocol is being used. See the bottom of the wikipedia page for the version supported in each desktop browser: http://en.wikipedia.org/wiki/WebSocket The IETF 6455 protocol was only finalized in Nov 2011. Safari 5.X and iOS 4.X have been out for much longer. Safari 6 supposedly has the latest protocol version but I haven't tested that. – kanaka Jul 31 '12 at 19:55
  • Thanks for the info, seems only logical. I found out it was indeed the problem... it seems in IOS 6, according to caniuse.com/websockets, they have 'full support' (read: finally implemented the right protocol). Really sucky to lagg behind on these things, Apple. – Michahell Aug 01 '12 at 10:51