2013-12-14 11:23



I am trying to implement WebSocket with php. And on my desktop computer It works correctly. But when I try to open my website on an android device. My server implementation gives the error below while handshaking.

Undefined index: Sec-WebSocket-Key

Then I checked the values. When I connected to web site with my desktop computers browser, Header contains Sec-WebSocket-Key index in header. But when I connected to web site from an android device, Header contains Sec-WebSocket-Key1 and Sec-WebSocket-Key2, but no Sec-WebSocket-Key. Therefore, It throws an exception. Is there any solution for this problem? Do I need two websokcet implementations, one for mobile and one for desktop?

Thanks in advance.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongming4994 dongming4994 8年前

    Sec-WebSocket-Key1 and Sec-WebSocket-Key2 are from early experimental drafts of the websocket proposal.


    That means your android device (be it the browser or some websocket library) doesn't support the final RFC6455 WebSocket Standard.

    To know what version your android device is using ...

    • Look for Sec-WebSocket-Version header, if found, that's your version.
      • Version 13 is RFC-6455 (the finalized spec)
    • Look for Sec-WebSocket-Draft header, if found, that's your draft (non-final) version.
    • Neither of these two, you have a super early draft, possibly hixie-75 or hixie-76 (as those were the first commonly implemented websocket specs)

    Version numbers are registered at the IANA WebSocket Version Number Registry. https://www.iana.org/assignments/websocket/websocket.xml

    点赞 评论 复制链接分享