Chrome 19中的Websockets异常(最新测试版) [英] Websockets anomaly in Chrome 19 (latest beta)
问题描述
我一直在使用websockets几个月来没有问题在Chrome和我的本地主机应用程序之间进行通信。突然之间,随着Chrome的最新版本,数据并没有经过干净。
在Chrome扩展的javascript中,代码的相关部分是:
window.ws = new WebSocket(ws:// localhost:13000 /);
window.ws.onopen = function(){
window.ws.send('GO');
在我的C#应用程序中:
string msg = ASCIIEncoding.UTF8.GetString(buffer);
Debug.WriteLine(msg);
几个月来,这工作得很好,我每天都会把GO退回去。现在我在接收缓冲区中得到的是4个字节 {114,247,7,0)
,在任何情况下都不会转换为GO编码我可以找到。任何人有任何想法会发生什么?我感到困惑,因为我没有碰过任何代码(铬或听众)结束。
干杯!
PS:全Chrome版19.0.1084.15 beta -m
原来,Chrome默认情况下在websockets上启用了压缩功能。我只需要修改我的一端的websocket服务器来拒绝该扩展,并且Chrome恢复为纯文本。I've been using websockets without an issue for months to communicate between Chrome and my localhost app. Suddenly, with the latest version of Chrome, data is not going through cleanly.
In the Chrome extension's javascript, the relevant part of the code is:
window.ws = new WebSocket("ws://localhost:13000/");
window.ws.onopen = function () {
window.ws.send('GO');
In my C# app:
string msg = ASCIIEncoding.UTF8.GetString(buffer);
Debug.WriteLine(msg);
For months this worked fine and I would get "GO" back out day in, day out. Now what I'm getting on the receiving buffer is 4 bytes {114,247,7,0)
which does not translate to "GO" in any encoding I can find. Anyone have any idea what could be happening? I'm bemused as I have not touched either end of code (chrome or listener).
Cheers!
PS: The full Chrome Version 19.0.1084.15 beta-m
Figured it out. Turns out Chrome has just enabled compression on websockets by default. I just needed to modify the websocket server on my end to refuse that extension and Chrome reverts to plain text.
这篇关于Chrome 19中的Websockets异常(最新测试版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!