6

I am using websocket in my app and everything worked fine when i was using localhost. The problem starts when i changed localhost to my server ip address then i got this error: Error during WebSocket handshake: Unexpected response code: 404

This is my httpd.conf

...

Listen 25.48.63.220:80
Listen 25.48.63.220:8081

...

ServerName 25.48.63.220:80

...

I think that i am able to connect with my server because when i typed wrong ip address i don't get this error.

What else i have to to change ?

Towkir
  • 3,889
  • 2
  • 22
  • 41

2 Answers2

0

404 means Not Found. Probably you are connecting to the wrong place, or you didn't map the port from your public IP address to your local IP address.

vtortola
  • 34,709
  • 29
  • 161
  • 263
0

I solved this problem. If you are using composer to download Ratchet you need to change constructor in /vendor/cboden/ratchet/src/Ratchet/App.php.

Default __construct should look like this:
 public function __construct($httpHost = 'localhost', $port = 80, $address = 'localhost', LoopInterface $loop = null) {

So you only need to change httpHost, port and address. It works for me :)

  • 3
    Please don't change the Ratcet\App constructor that you get through Composer. Just pass your values to the Ratchet\App constructor: $ws = new Ratchet\App($httpHost='localhost', $port=80, $address='localhost', $loop=null); – dmiller309 Sep 01 '14 at 20:44