2

After developing most of the site, I needed to introduce the ability to push data from the server to client. After some research I decided to use Ratchet (I'm using Laravel 4.1).

I've implemented my pushUpdate class, but I'm having issue starting the webSocket server, My current approach to start the server is:

    // Run the server application through the WebSocket protocol on port 8080
    $app = new Ratchet\App('localhost', 8080);
    $app->route('/update', new pushUpdate);
    $app->route('/echo', new Ratchet\Server\EchoServer, array('*'));
    $app->run();

This code is ran when the page that requires push update is requested. This is the error I receive:

   React \ Socket \ ConnectionException
   Could not bind to tcp://127.0.0.1:8080: Address already in use

I haven't implemented a webSocket before, I've read the server config doc (http://socketo.me/docs/deploy#serverconfiguration) which states I can run both web and socket servers on port 8080.

any help to solving this is highly appreciated.

Moe
  • 470
  • 1
  • 9
  • 26

1 Answers1

4

Sounds like you have a process already using port 8080. You can see if that is the case by using "netstat -ap" to see what process is using 8080.

shucklak
  • 56
  • 3
  • Yes, I have my server running on 8080. This is because I got the impression from the document I can run both "Run your website and WebSocket server on the same machine using port 8080 for WebSockets and take the chance client proxies won't block traffic" – Moe Mar 20 '14 at 18:00
  • I'm not entirely familiar with Websockets so I cannot comment on that. But I am familiar with TCP, and you shouldn't share listen sockets :) – shucklak Mar 20 '14 at 18:06
  • 2
    `netstat -ap` says nothing is using 8080 :P – Joseph Garvin Mar 08 '21 at 15:55