Websockets on ipad, is there something extra that needs to be done?

爱⌒轻易说出口 提交于 2019-12-24 09:43:02

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/9894934/websockets-on-ipad-is-there-something-extra-that-needs-to-be-done

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!