Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix getting started wiki page (was: share js client can't find socket.io.js) #153

Closed
raph-amiard opened this Issue · 8 comments

6 participants

@raph-amiard

Hi, i have tried to install share-js as per the procedure found in the wiki, with the same example code for the server and for the client. Here is the server code :

var connect = require('connect'),
sharejs = require('share').server;

var server = connect(
    connect.logger(),
    connect.static(__dirname + '/public')
);
var options = {db: {type: 'none'}}; // See docs for options. {type: 'redis'} to enable persistance.

// Attach the sharejs REST and Socket.io interfaces to the server
sharejs.attach(server, options);

server.listen(8000, function(){
    console.log('Server running at http://127.0.0.1:8000/');
});

and here is the client code (html file) :

<html>
  <head>
    <script src="http://ajaxorg.github.com/ace/build/src/ace.js"></script>
    <script src="/socket.io/socket.io.js"></script>
    <script src="/channel/bcsocket.js"></script> 
    <script src="/share/share.js"></script>
    <script src="/share/ace.js"></script>
  </head>

  <body>
    <div id="editor"></div>
    <script>
      var editor = ace.edit("editor");

      sharejs.open('hello', 'text', {host: 'localhost', port: 8000}, function(doc, error) {
        doc.attach_ace(editor);
      });
    </script>
  </body>

</html>

It fails with the error : "socket.io.js : Failed to load resource: the server responded with a status of 404 (Not Found)"

@obijywk

socket.io is disabled in ShareJS by default - I think you at least need to include a 'socketio' key in your ShareJS attach options to cause ShareJS to set it up.
https://github.com/josephg/ShareJS/blob/master/src/server/index.coffee#L49

Furthermore I think you might also have to make some additional call to tell socket.io to serve it's client library from "/socket.io/socket.io.js" - I'm not familiar with socket.io so I'm not sure how or even if this needs to be done.

@raph-amiard

Hi,

i don't necessarily want to use socket.io, i just want it to work. Even if you remove the socket.io.js line, it still fails with an error : "bcsocket.js:90Uncaught TypeError: Object # has no method 'match'".

Executing bin/example_server and accessing the client page gives the same error.

So i guess the question is , how do you make share js (any version) work ?

@obijywk

BrowserChannel is probably the easiest way to just get it working. Try using these options:
var options = {db: {type: 'none'}, browserChannel: {}};
and removing the socket.io script tag, and see if it works.

That still doesn't explain your error "bcsocket.js:90Uncaught TypeError: Object # has no method 'match'" though, I'm not sure what's causing that.

@josephg
Owner
@athibaud

hi all, i was with @raph-amiard earlier when we experienced those issues but actually there is no issue, at least with the current version of sharejs/browserchannel there isn't.

thing is, we followed the code described in the wiki which seems outdated for it instructs to include the socket.io script on the client. that probably resulted in the 404 business.

so then we simply removed the socket.io script tag and we had issue #141 and yeh... that isn't really an issue

so, we just did what we probably should have done in the first place and used the code on the README page... and that works like a charm!

the issue should be renamed to 'wiki out of date'. sorry for the hassle and yeh, updating the wiki would be nice!
also @josephg, is that still the case??

ps: @daredevildave we tried this out also, but it seems like it doesn't work... thought i'd let you know.

@josephg
Owner
@wmertens
Collaborator

@raph-amiard @athibaud feel free to edit the wiki, much obliged :-)

@kishorenc

I have edited the wiki to remove the socket.io include. This issue can be closed.

@josephg josephg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.