Bug 1009271

Summary: Failed to wake up idled app via websocket request
Product: OpenShift Online Reporter: chunchen <chunchen>
Component: ContainersAssignee: Jhon Honce <jhonce>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.xCC: wsun, xtian
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-10-17 13:29:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description chunchen 2013-09-18 06:07:30 UTC
Description of problem:
When creating an app,idle this app,then access page via websocket, it's failed to wake up this app to start and get 503 error for page.

Version-Release number of selected component (if applicable):
fork_ami_origin_runtime_232_834

How reproducible:
always

Steps to Reproduce:
1. Create a fork_ami instance
2. Log into site at https://devenv/app/console
3. Create an AeroGear app named "caerosocket"
4. SSH into this instance and idle this app
oo-admin-ctl-gears idlegear 5239165978550ce0ab000002
5. Access this app page via browser
http://caerosocket-cdm.dev.rhcloud.com:8000/simplepush/info
https://caerosocket-cdm.dev.rhcloud.com:8443/simplepush/info
6. Check the status of app
rhc app show caerosocket --state

Actual results:
at Step 5: return 503 page
at Step 6: Cartridge aerogear-aerogear-push-0.8.0, mysql-5.1 is idle

Expected results:
Idled app should be waken up via websocket request.

Additional info:

Comment 1 Jhon Honce 2013-09-20 22:52:19 UTC
Feature enabled in https://github.com/openshift/origin-server/pull/3677

Comment 2 Jhon Honce 2013-09-23 22:53:31 UTC
For testing you require a websocket enabled server and client...

    Add dependency to package.json:
    :
    .
      "dependencies": {
        "ws" : ">0.4.30"
      },
     
     
    Replace server.js to support web sockets:
     
    var host = process.env.OPENSHIFT_NODEJS_IP;
    var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
     
    var WebSocketServer = require('ws').Server,
        wss = new WebSocketServer({host: host, port: port});
        wss.on('connection', function(ws) {
          ws.on('message', function(message) {
            console.log('received: %s', message);
          });
          ws.send('something');
        });
     
     
    For a client:
    wscat -c ws://node001-honcenet.dev.rhcloud.com:8000/ -p 8

Every message you type, should be logged in /var/lib/openshift/<uuid>/nodejs/logs/node.log.

Comment 3 Jhon Honce 2013-09-23 22:58:43 UTC
Merged onto master by https://github.com/openshift/origin-server/pull/3688

Comment 5 chunchen 2013-09-24 09:19:50 UTC
It's fixed, verified on devenv_3817, please refer to the following results:

1. Create a nodejs app
rhc app create nod1 nodejs-0.6
2. Replace server.js to support web sockets:
     
    var host = process.env.OPENSHIFT_NODEJS_IP;
    var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
     
    var WebSocketServer = require('ws').Server,
        wss = new WebSocketServer({host: host, port: port});
        wss.on('connection', function(ws) {
          ws.on('message', function(message) {
            console.log('received: %s', message);
          });
          ws.send('something');
        });
3. Add dependency to package.json:
    :
    .
      "dependencies": {
        "ws" : ">0.4.30"
      },
4. Push the changes
5. SSH into instance and idle this app
oo-admin-ctl-gears idlegear 52415129b723cc8c72000039
6. Access this app via websocket
wscat -c wss://nod1-cdm.dev.rhcloud.com:8443/ -p 8
or
wscat -c ws://nod1-cdm.dev.rhcloud.com:8000/ -p 8
7. Check the state of this app
# rhc app show -a nod1 --state
Cartridge nodejs-0.6 is started