2

I'm running a real time web application which uses Symfony 2 PHP framework on the backend. I want to implement websockets for my real time interaction. Is it possible to install a node.js server on the same machine as my Symfony 2 server to handle websocket connections? If so, is it standard to open another port (say 81) to handle the websocket connection?

1 Answer 1

2

Yes, it is possible. Why not? It's just another application.

As for the second question. You can either open another port, which is easy to handle (WebSockets are not limited with cross-origin policy) but you may lose some data (cookies) or you can put a proxy which will send HTTP requests to web server and WS requests to Node.JS server. The latter can be recognized by having special header Upgrade: websocket. Either way WebSocket server has to listen on different port (unless you are developing application entirely in Node.JS).

Sign up to request clarification or add additional context in comments.

2 Comments

For your second point I do not agree. A Websocket is Raw Tcp and not HTTP, so you will need a exposed port runnning node.js when using real websockets
@mblaettermann That's not true. Websocket connection starts as a normal HTTP connection and afterwards is upgraded to TCP. Besides both TCP and HTTP can be handled on the same port (why not?). The only reason people don't do that is because the code would be a bit difficult to maintain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.