0

Server

var express = require('express');
var app = express();
var connect = require('connect');
var sharejs = require('share').server;
var server = connect(
  connect.static(__dirname + '/public/client/')
  );
var options = {db: {type: 'none'}};
sharejs.attach(server, options);

**var server = http.createServer(app).listen(app.get('port'), function(){
});**

client

<script src="/channel/bcsocket.js"></script>
<script src="/client/share/share.js"></script>
<script src="/share/ace.js"></script>

Error

**GET http://localhost:3000/channel/bcsocket.js 404 (Not Found)**

**GET http://localhost:3000/share/share.js 404 (Not Found)**

**GET http://localhost:3000/share/ace.js 404 (Not Found)**

I'm unable to connect to client and server. I can't figure out what went wrong

Amit
  • 66
  • 9
  • Which is the path of the Server js file? Make sure the connect.static path is correct. – klode Mar 09 '14 at 01:19
  • its correct path bro still not getting..... even tried with all possible paths – Amit Mar 10 '14 at 10:31
  • Also, looks like you are not starting any server in the Server file. Is the last line in the Server file a comment (/** comment **/), otherwise what is app? – klode Mar 10 '14 at 14:22
  • its not commented as stackoverflow is not accepting that way for posting question so I've to comment it in posting – Amit Mar 11 '14 at 05:21
  • The variable app is never defined, and the var server is defined twice. Looks like the the server file you posted is not the whole file, is not possible to figure out what you are trying to do if you do not post the whole file. – klode Mar 11 '14 at 14:34
  • thank bro i figured out stuff thanks for helping me i've to use app instead of server in "sharejs.attach(server, options);" – Amit Mar 13 '14 at 13:49
  • I am happy I helped you debugging. But app is not defined in the code you posted. I would suggest to post the whole code when you ask a question, otherwise it is not possible to evaluate the problem and give you an answer, and becomes a bit of a loss of time for people trying to help. – klode Mar 13 '14 at 14:20

1 Answers1

0

Looks like the scripts cannot be found.

If server.js is in myapp/server.js, the following

connect.static(__dirname + '/public/client/')

will serve static files form the myapp/public/client/ folder.

Therefore, if the share.js file is in myapp/public/client/share/share.js, in the client.html you would have

<script src="/share/share.js"></script>

Also, you should configure the server to listen

var connect = require('connect');
var sharejs = require('share').server;
var server = connect(
      connect.static(__dirname + '/public/client/')
  );
var options = {db: {type: 'none'}};
sharejs.attach(server, options);

/** configure the server to listen on a port **/
server.listen(3000);
klode
  • 10,821
  • 5
  • 34
  • 49
  • you should configure the server to listen, see the reedited answer. – klode Mar 10 '14 at 14:56
  • I tried the way u said it working but it arise new issues.that i cannot route to other page all other working pages not loading like localhost:3000/login stopped working. only that page is loaded correctly. – Amit Mar 11 '14 at 05:30