dongzhenshen7435 2012-05-08 00:08
浏览 128
已采纳

Websockets无法解决“收到意外的延续帧”错误

I wrote an algorithm to process Websockets data in PHP. Decoding from Chrome/Firefox is fine, but I'm consistently having a problem sending data from the server to the client (Chrome 18, Websockets 13). The server routine automatically responds with "Received" after receiving a message.

Continuation frame error.

There are absolutely no other bytes following the message, as the STDOUT indicates and the WireShark dump indicates (data retrieved via RawCap). In WireShark/RawCap, for some reason, the server->client message appeared under an "ACK" message.

STDOUT

Wireshark

I would REALLY appreciate someone's insight on this. It's driving me crazy.

Dustin Oprea

  • 写回答

1条回答 默认 最新

  • dpp78272 2012-05-08 14:00
    关注

    I got it. It turns out that the code that I originally adopted put a single NULL character after the newlines following the handshake-response headers, and I hadn't noticed this. It looks like a) the browser moves all of the received websocket messages through a character buffer that leaves the single NULL character at the front once the authentication-response is processed, and b) it wasn't a problem until the -next- message was received.

    Flow:

    1) Browser (Chrome and Firefox) receives a handshake-response with an extra NULL on the end.
    2) Browser approves handshake response.
    3) Browser sends a message (in this case, with a "text" opcode, not that it necessarily matters) to the server.
    4) Server correctly decodes frames.
    5) Server sends a message back through established websocket session.
    6) Client complains about having an unexpected continuation frame.

    Under some conditions, I believe that I was able to manipulate the message to suppress an error from the browser, but still did not receive the server-message in the browser.

    As an example of the above, I believe that, originally, the server was sending an automatic text response of "response", and got the message above. I later changed this to "1234", and still got the message above. However, I changed this to "123", and no longer got the error, but still did not get a message event in the Javascript.

    Dustin Oprea

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题