Websocket在Firefox中失败 [英] Websocket fails in Firefox
问题描述
以下是javascript代码:
var address ='ws://'+ window.location.host +':8080 / ws';
client = new WebSocket(address);
我已经使用浏览器测试了连接:
Chrome(Windows和OS X) ,Safari(OS X和iPhone),Opera(Windows),Android Browser,以及Panasonic TV上的浏览器。 X)。我已经尝试过从版本5到40的多个版本的Firefox。我也尝试过使用MozWebSocket,但没有用。
我得到的错误是:
Firefox无法在ws://192.168.0.100:8080 / ws建立到服务器的连接。
在加载页面时,连接ws://192.168.0.100:8080 / ws被中断。
Firefox与其他浏览器有什么不同?
您有什么建议吗?
这个问题与Sec-WebSocket-Extensions:permessage-deflate有关。在Firefox的about:config中设置network.websocket.extensions.permessage-deflate为false解决了这个问题。
另外从websocket服务器禁用permessage-deflate可以解决问题。
I am using PocketSocket as a LAN WebSocket server (on port 8080) on iOS and I connect to it using javascript.
Here is the javascript code:
var address = 'ws://' + window.location.host + ':8080/ws';
client = new WebSocket( address );
I have tested the connection using the fallowing browsers: Chrome (Windows and OS X), Safari (OS X and iPhone), Opera (Windows), Android Browser, the browser on Panasonic TV.
The only browser that it failed was Firefox (Windows and OS X). I have tried multiple versions of Firefox from version 5 to 40. I have also tried using MozWebSocket, but at no avail.
The error that I get is:
Firefox can't establish a connection to the server at ws://192.168.0.100:8080/ws.
The connection to ws://192.168.0.100:8080/ws was interrupted while the page was loading.
What is different in Firefox from the other browsers? Do you have any suggestions?
The problem had to do with "Sec-WebSocket-Extensions: permessage-deflate". Setting network.websocket.extensions.permessage-deflate to false in about:config inside Firefox solved the problem.
Also disabling permessage-deflate from the websocket server would fix the problem.
这篇关于Websocket在Firefox中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!