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 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch