WebSocket connection to OpenShift app failed

前端 未结 2 1472
面向向阳花
面向向阳花 2020-12-09 05:41

I created an app with NodeJS and I\'m using ws module. If I test the app in localhost it works and there isn\'t any problem to connect websockets. Now I\'ve upload the app t

相关标签:
2条回答
  • 2020-12-09 06:26

    For all WebSocket connections on OpenShift you need to use port 8000 (for Secured sessions it would be 8443). So, your server example works well (I run them after removing the unnecessary line var Enum = require('enum');, you just need to hardcode the port on client to 8000:

    var ws = new WebSocket("ws://YourApp-YourName.rhcloud.com:8000"); 
    
    ws.onopen = function(){
      console.log('opened')
    }
    

    More information here.

    0 讨论(0)
  • 2020-12-09 06:27

    Here is an example on github that works that you can check out: https://github.com/developercorey/openshift-nodejs-http-and-websocket-example

    0 讨论(0)
提交回复
热议问题