Websockets无法解析“收到意外的连续帧”错误 [英] Websockets unresolvable "received unexpected continuation frame" error

查看:2152
本文介绍了Websockets无法解析“收到意外的连续帧”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个算法来处理PHP中的Websockets数据。从Chrome / Firefox解码是好的,但我一直有一个问题,从服务器发送数据到客户端(Chrome 18,Websockets 13)。服务器程序收到消息后自动回复已收到。



客户端消息出现在ACK消息中。





我真的很感谢某人对此的洞察力。这是令我疯狂的。



Dustin Oprea

解决方案

。事实证明,我原来采用的代码在握手响应头文件之后的换行符之后放置了一个NULL字符,而我没有注意到这一点。它看起来像a)浏览器通过一个字符缓冲区移动所有接收到的websocket消息,一旦认证响应被处理,在前面留下单个NULL字符; b)直到-next-消息才是问题被收到。



浏览器(Chrome和Firefox)收到握手响应额外的NULL结束。

2)浏览器批准握手响应。

3)浏览器发送一个消息(在这种情况下,与文本操作码,不是必要的)到服务器。
4)服务器正确地解码帧。

5)服务器通过建立的websocket会话发回一个消息。

6)客户抱怨有一个意想不到的延续框架。

在某些条件下,我相信我能够操纵消息来抑制浏览器的错误,但仍然没有在浏览器中接收服务器消息。



作为一个例子以上,我相信,原来,服务器正在发送一个响应的自动文本响应,并得到上面的消息。我后来改成了1234,还是收到了上面的消息。不过,我把这个改为123,不再有错误,但仍然没有在Javascript中得到一个消息事件。


$ b $ d Dustin Oprea


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.

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.

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

Dustin Oprea

解决方案

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

这篇关于Websockets无法解析“收到意外的连续帧”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆