Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor polling error when running as middleware #56

Closed
brianmcmichael opened this issue Feb 19, 2016 · 6 comments
Closed

Editor polling error when running as middleware #56

brianmcmichael opened this issue Feb 19, 2016 · 6 comments

Comments

@brianmcmichael
Copy link
Contributor

App is running as express middleware with prefix pun/dev/cloudcmd/

The default editor is attempting to poll socket.io on the server, but it is affixing the entire app prefix, which includes the cloudcmd app name. The socket.io app was deployed by the installer into the same node_modules directory as the cloudcmd app, so the appropriate prefix would be pun/dev/socket.io in this case.

It seems that the editor needs to be informed to step back a directory from the prefix to connect to socket.io. Alternatively, cloudcmd maintains it's own node_modules folder, but socket.io isn't present in that path. Perhaps adding socket.io to cloudcmd/node_modules/socket.io would also resolve this issue. I haven't had a chance to experiment with it yet, but I'm reporting it here in case you have any thoughts.

The editor begins polling on open:
pollingerror

Poller gets 404 from invalid path:
pollingerror2

@coderaiser
Copy link
Owner

Thank you, I will think about it. Which version of Cloud Commander and socket.io you use?

@coderaiser coderaiser added the bug label Feb 20, 2016
@brianmcmichael
Copy link
Contributor Author

cloudcmd 5.0.15
socket.io 1.4.5

Here's how the folders are structured on the system.

bmcmichael@websvcs02:~/ood_dev/cloudcmd$ ll
total 16
drwxr-xr-x 3 bmcmichael appl 4096 Feb 11 12:14 ./
drwxr-xr-x 4 bmcmichael appl 4096 Feb 16 16:19 ../
-rw-r--r-- 1 bmcmichael appl  649 Feb 16 10:11 app.js
drwxr-xr-x 6 bmcmichael appl 4096 Feb 16 12:01 node_modules/

bmcmichael@websvcs02:~/ood_dev/cloudcmd$ tree -d -L 3
.
`-- node_modules
    |-- cloudcmd
    |   |-- bin
    |   |-- css
    |   |-- font
    |   |-- html
    |   |-- img
    |   |-- json
    |   |-- lib
    |   |-- man
    |   |-- modules
    |   |-- node_modules
    |   |-- shell
    |   |-- test
    |   `-- tmpl
    |-- express
    |   |-- lib
    |   `-- node_modules
    `-- socket.io
        |-- lib
        `-- node_modules

21 directories
bmcmichael@websvcs02:~/ood_dev/cloudcmd$

@coderaiser
Copy link
Owner

You should add path on socket.io init with prefix you going to use like in lib/server.js.

Added this information to docs.

All this things made in this way to make prefixes work around all Cloud Commander's middleware.

@brianmcmichael
Copy link
Contributor Author

Thanks, I'll try that!

@brianmcmichael
Copy link
Contributor Author

I found the issue.

edit.js is using CloudCmd.PREFIX instead of the actual socket path.

socketPath: CloudCmd.PREFIX

I am able to fix this by manually eding the socketPath var to my socket path, ex. pun/dev/socket.io, but I am new to express and I haven't figured out how to get the Socket's path variable into the edit.js yet.

This also appears to be an issue in konsole.js

socketPath = CloudCmd.PREFIX;

Also, I'm not sure that the updates to the README.md regarding prefixing the path are correct. My app.js currently for the middleware app currently looks like:

socket = io.listen(server, {
  path: '/pun/dev/socket.io'
});

app.use(cloudcmd({
    socket: socket,                   /* used by Config, Edit (optional) and Console (required)   */
    config: {                         /* config data (optional)                                   */
      root: homeDir(),  
      prefix: '/pun/dev/cloudcmd',  /* base URL or function which returns base URL (optional)   */
    }
}));

@brianmcmichael
Copy link
Contributor Author

Disregard. I seem to have managed to fix it in the socket path. Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants