Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get socket.io running for a subdirectory

I've got a proxy running that only hits my node.js server for paths that being with /mysubdir How do I get socket.io configured for this situation?

In my client code I tried:

var socket = io.connect('http://www.example.com/mysubdir'); 

but then I notice that the underlying socket.io (or engine.io) http requests are hitting

http://www.example.com/socket.io/?EIO=3&transport=polling&t=1410972713498-72` 

I want them to hit

http://www.example.com/mysubdir/socket.io..... 

Is there something I have to configure on the client and the server?

like image 529
Drew LeSueur Avatar asked Sep 17 '14 16:09

Drew LeSueur


People also ask

How many rooms can Socket.IO handle?

socket.io rooms are a lightweight data structure. They are simply an array of connections that are associated with that room. You can have as many as you want (within normal memory usage limits). There is no heavyweight thing that makes a room expensive in terms of resources.

How many messages per second can Socket.IO handle?

Both server and client node processes use 95-100% of a CPU core each. So pure throughput looks ok. I can emit 100 messages per second to 100 local clients at 55% CPU usage on the server process.


1 Answers

In my server I had to

var io = require('socket.io')(httpServer, {path: '/mysubdir/socket.io'})` 

In my client I had to

<script src="http://www.example.com/mysubdir/socket.io/socket.io.js"></script> 

and also

var socket = io.connect('http://www.example.com', {path: "/mysubdir/socket.io"});` 
like image 117
Drew LeSueur Avatar answered Sep 20 '22 22:09

Drew LeSueur