Re: CloudFoundry websocket failed: Establishing a tunnel via proxy server failed
Nicholas Calugar
Hi Behroz,
toggle quoted message
Show quoted text
There are a couple items to consider when doing web sockets on Cloud Foundry. 1. Port 4443 is recommended for load balancers that don’t support passing the WebSocket handshake requests to the CF router on the same port as HTTPS. [1] Read more about this here. You’ll have to confirm this setup with your operator, the person that manages your Cloud Foundry deployment. 2. If your app server does not support upgrading to WebSocket, you’ll have to open an additional port using the Cloud Foundry API, you can use any port in the range 1024-65535. [2] The application update endpoint takes a list of ports, remember you’ll still want 8080 open for your REST API. Please note, this is an experimental feature and it is not related to the port mentioned above on the load balancer. 3. If you are using an additional port for WebSockets, you’ll need an additional route and route mapping to use that port. [3] See the mapping an app and a route documentation. Hope this helps, I’ve actually never tried it but it is supported. [1] https://docs.cloudfoundry.org/adminguide/supporting-websockets.html#config [2] http://apidocs.cloudfoundry.org/247/apps/updating_an_app.html [3] http://apidocs.cloudfoundry.org/247/routes_mapping/mapping_an_app_and_a_route.html -Nick -- Nicholas Calugar Product Manager - Cloud Foundry API Pivotal Software, Inc. On November 19, 2016 at 4:21:22 AM, Behroz Sikander (bsikander(a)apache.org)
wrote: Note: I am not using Pivotal CF. I have a java application deployed on CloudFoundry. I am using embedded Jetty to host my Jersey REST API. This API is by default exposed on port 8080 by cloud foundry. My application also needs some websockets to stream data to the browser. I am using Java-WebSocket (https://github.com/TooTallNate/Java-WebSocket) for this. On my local machine, I was using port 8887 for my websocket connection. Everything worked fine. After deploying on CloudFoundry, I can access my REST API but not my websocket. After searching a bit online, I found that websocket connections are only allowed on port 4443 (http://docs.run.pivotal.io/release-notes/) I changed my server side to reflect this import org.java_websocket.server.WebSocketServer; public class MyWebSocket extends WebSocketServer { public MyWebSocket() throws UnknownHostException { super(new InetSocketAddress(4443)); } @Override public void onOpen(org.java_websocket.WebSocket websocket, ClientHandshake handshake) { // Handle this } } On my client side, I am connecting the websocket using the following wss://my_cf_app.com:4443/ But I am getting the following exception. "WebSocket connection to 'wss://my_cf_app.com:4443/' failed: Establishing a tunnel via proxy server failed" I also tried to connect the websocket on server side using "PORT" environment variable of CF but I get "Address already in use" error in Java-WebSocket because 8080 is already taken by Jersey REST API. I have tried many different things but I am unable to figure this out. Any help would be awesome. |
|