Change Socket.IO static file serving path

I am using Socket.IO on a Node server with a basic HTTP server (no Express or Connect or anything like that). By default, Socket.IO serves the client file to


I would like to be able to change that base path to something else, like


Is there any built-in way to do this, or any way without changing Socket.IO's code? I think the answer lies in the Static module (require('').Static)), but short of writing my own to replace the default, I see no way to go and change the way that behaves.

How can I do this?


The resource option allows you to configure's root directory. It defaults to /

var io = require('').listen(app, { resource: '/foo/bar/' });

Note that this setting also affects where's endpoints are served from, so you must also change this setting in your client code.

var socket = io.connect('', { resource: 'foo/bar/' });

(Note we don't use a leading slash here for some reason.)

For version 1.2.1, this works for me.

Server side:

var io = require('')({path: '/foo/bar'});

Client side:

var socket = io.connect('', {path: '/foo/bar'});


If you are using version 1.0, the configuration is different than in previous versions.

For client side:

var socket = io.connect('http://localhost:8888', { path: '/some/path/' });

For server side

    var socket = require("")( { resource: '/some/path/' });

You can find the client side script in the path node_modules/ Copy it to a new folder and call it with the correct path from the client

<script src="/your/path/to/"></script>

For more configuration visit the wiki

Need Your Help

Doctrine2 - Multiple insert in one shot

php mysql symfony doctrine-orm

I'm new to Doctrine and there are still some blurred areas for me. In this case I'm inserting new record in the database using a loop and the entity manager. It works fine but I noticed that Doctrine

Switching ViewControllers with UISegmentedControl in iOS5

ios uiviewcontroller uikit uisegmentedcontrol

I am trying something very simple but somehow I can't get it to work. All I try to do is switching between 2 View Controllers using an UISegmentedControl as you can see it for example in the App St...