In the past years it has become easier to create a nodejs app and special ports for websockets are now available even for shared servers, both via https://my.webfaction.com/new-application. Combining these two however is not trivial: the 'App category' widget lets you choose between a 'Node' app and a 'Websockets app'. If your want your Node app to use websockets, you need to choose 'websockets' and then install the Node part somehow yourself, although it says that 'the custom application (read: Node) is not required to reside there (read: in the newly created Websocket app directory). Creating a Node app first, then the 'Websocket app' and using the port given from this websocket app in the Node app to listen to, does not work. So what is the suggested way at this date (2016) to create a Node app that uses websockets, e.g. with the socket.io module? asked 27 Apr '16, 16:13 expdesign |
Actually it does, and is the recommended way to do Node with websockets on our platform. The specific steps are:
If you've done that and it's not working for you, then feel free to open a support ticket to let us know the specific problem you're seeing. Hope that helps! answered 27 Apr '16, 16:25 seanf "Configure your site in the control panel to use the websockets app instead of the node app": counter-intuitive but a very important hint. Also, in case of using socket.io, the option 'path' for the io.connect function should end on /socket.io/, eg, when the website for the websocket app is subdomain '/ws', use io.connect('/',{path:'/ws/socket.io'});
(28 Apr '16, 12:00)
expdesign
@seanf Correct me if I'm wrong. Right now (2019) the step n.4 is not needed. As far as I understand, the step n.2 is enough to connect the custom websocket apps port to the internet (I checked the flag "Open a port in the server firewall for the application."). This is what made my socket work. Without the flag checked, it didn't work (even with step n.4 accomplished). Am I right? Can you shed some light on the subject? Vito
(30 May '19, 07:35)
tecnosoft
@tecnosoft how are you attempting to make the connection? Can you post your ws client code in a comment here?
(30 May '19, 14:27)
seanf
@seanf Reduced to bare minimum, my code was the following:
websocketip:websocketport are IP and port obtained from "Custom websockets app (listening on port)", and it works (with firewall open checked!). When I had a website in place (I deleted it) and no firewall open checked, I tried with each combination I could imagine (actually 4: I had 2 IPs (one for "node" and one for "Custom websockets") and 2 ports (again one for "node" and one for "Custom websockets") with no luck.
(30 May '19, 15:41)
tecnosoft
(30 May '19, 15:54)
seanf
@seanf Whoa! I made it more complicated than it is! You are right, I just created the new website, closed the firewall port and the connection to http://websocketip works flawlessly! Now it's clear. Many thanks!
(31 May '19, 07:29)
tecnosoft
showing 5 of 6
show 1 more comments
|