php_nub_qq
php_nub_qq

Reputation: 16055

Websockets can't connect to server

I am trying to obtain some education on websockets but I can't really find a decent tutorial. All tutorials out there instruct you to download a server and teach you how to use it. I'm more interested in how the server actually works and how I can control it on a remote host, like a hosting provider.

Anyway if I wanna learn there really aren't many options other than to download a built server and start inspecting. So I downloaded the server given in this tutorial http://dev.tutsplus.com/tutorials/start-using-html5-websockets-today--net-13270

The problem for now is that I can't even seem to connect to it. I'm running XAMPP on Win7, so it's completely relevant to the tutorial and appears quite easy, however I fail. I've managed to start the server, but when I open client.php I get

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

Fortunately chrome appears to provide a more detailed error message

WebSocket connection to 'ws://localhost:8000/pol/newWS/server/startDaemon.php' failed: Error during WebSocket handshake: 'Sec-WebSocket-Accept' header is missing

Javascript's host variable is set to 'ws://localhost:8000/pol/newWS/server/startDaemon.php', that's where the server is located on my localhost. I haven't made any changes to the server. Can anyone help me get this thing going? Thanks in advance!

Upvotes: 0

Views: 2381

Answers (2)

php_nub_qq
php_nub_qq

Reputation: 16055

I just found some WS server I have downloaded in the past which works pretty well. I can't confirm for any security issues but if anyone knows or finds anything please don't spare us the sharing. I searched for some info in the comments but I couldn't find anything about the creator so I can't really give any credits.

files here

Upvotes: 0

Hans
Hans

Reputation: 353

Websockets in PHP are generally a pain in the ass. Even if you use a library like rachet you need to start it separately, not through a webserver.

As brad said, consider using node.js or the excellent autobahn.ws for python.

Upvotes: 0

Related Questions