Friday 14 April 2017

Not able to connect to Websockets on Heroku

I have been working on an PHP Laravel Application for which I have been using Redis and Node.JS to get connected to the WebSocket.

So in order to achieve that I have been trying to run the node server on port 3000 but heroku is dynamically allocating the port.

Because of this I am unable to get the correct port no on client side.

What should I do in order to fix it ?

Client side config :

var socket = io.connect('http://app-around.herokuapp.com:3000');
  Note: Host Name is app-around.herokuapp.com

Backend is Running Fine as shown below:

    C:\xampp\htdocs\around-us>heroku run node socket.jsRunning node 
   socket.js on app-around... up, run.5567 (Free)
    // Randomly generated port number it is..

   Message Recieved: {"event":"App\\Events\\NewMessage","data":{"data":
    {"message":"Question Posted"}},"socket":null}

So events are getting generated on the Server side but am not able to receive them on the client side. Tried several things on Front End but none of them is working:

    Eg: 1) var socket = io.connect();
        2) var socket = io.connect(window.location.hostname);



via Honey Thakuria

No comments:

Post a Comment