Can't establish a connection to the server at ws://localhost:8000/socket/server/startDaemon.php. var socket = new WebSocket(host);

Sanjeev Kumar Jha picture Sanjeev Kumar Jha · May 30, 2011 · Viewed 49.1k times · Source

I am using javascript to connect websocket:

<script>
    var socket;  
    var host = "ws://localhost:8000/socket/server/startDaemon.php";  
    var socket = new WebSocket(host);  
</script>

I got the error:

Can't establish a connection to the server at

var host = "ws://localhost:8000/socket/server/startDaemon.php";
var socket = new WebSocket(host);

How can I solve this issue?

NOTE : I enabled websocket in mozilla to support web socket application. and when i run in chrome i got error:

   can't establish a connection to the server at ws://localhost:8000/socket/server/startDaemon.php. var socket = new WebSocket(host);

Answer

Ibu picture Ibu · Jun 2, 2011

Apparently firefox 4 has websockets disabled because of vulnerabilities. To quote From this article:

WebSocket disabled in Firefox 4

Recent discoveries found that the protocol that Websocket works with is vulnerable to attacks. Adam Barth demonstrated some serious attacks against the protocol that could be used by an attacker to poison caches that sit in between the browser and the Internet.