Unexpected response code 426

前端 未结 1 1701
谎友^
谎友^ 2021-01-14 16:48

I am using Tomcat websockets and it is working fine in all browsers except in Safari where it is throwing Unexpected response code 426 error.
I went through

1条回答
  •  孤城傲影
    2021-01-14 17:39

    The 426 response code on upgrade is appropriate for when your websocket client is not conforming to the WebSocket standard RFC-6455.

    See Section 4.2.2. Sending the Server's Opening Handshake. http://tools.ietf.org/html/rfc6455#section-4.2.2

       /version/
          The |Sec-WebSocket-Version| header field in the client's
          handshake includes the version of the WebSocket Protocol with
          which the client is attempting to communicate.  If this
          version does not match a version understood by the server, the
          server MUST abort the WebSocket handshake described in this
          section and instead send an appropriate HTTP error code (such
          as 426 Upgrade Required) and a |Sec-WebSocket-Version| header
          field indicating the version(s) the server is capable of
          understanding.
    

    What is going on, is that Safari 5.x isn't using the final WebSocket spec, but rather an early experimental draft version, something that tomcat does not correctly support. Few production servers do anymore.

    For more information see What browsers support HTML5 WebSocket API? and http://caniuse.com/websockets

    0 讨论(0)
提交回复
热议问题