Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Connecting to sockets on a path #80

Closed
paranoid-android opened this issue Jun 15, 2017 · 1 comment
Closed

Connecting to sockets on a path #80

paranoid-android opened this issue Jun 15, 2017 · 1 comment

Comments

@paranoid-android
Copy link

Steps to reproduce

Hello,
First, thank you for creating this module for Feathers. I have an app that has a number of pages. Only two of my pages require sockets. I need to have two different socket paths. For example:

  • /logs/feed
  • /customer-support/chat

In an attempt to do this, I have the following Feathers app setup:

const feathers = require('feathers');
const socketio = require('feathers-socketio');

const app = feathers();
const routes = require('./routes');

app.configure(configuration(path.join(__dirname, '..')));

app.use(compress())
  .options('*', cors())
  .use(cors())
  .use('/public', serveStatic(app.get('public'), staticFileSettings ))
  .use(bodyParser.urlencoded({ extended: true }))
  .configure(routes)
 .configure(socketio())  

In my routes file, I have paths like:

app.get('/logs/feed', function(req, res) {
  app.io.on('connection', function(socket) {
    console.log('connected to log feed!');
    socket.emit('client-connected', { result: 200 });
  });
  res.render('/logs/feed', {});
});

app.get('/customer-support/chat', function(req, res) {
  app.io.on('connection', function(socket) {
    console.log('connected to customer support chat');
    socket.emit('client-connected', { result: 200 });
  });
  res.render('/customer-support/chat', {});
});

In my app, I then try to connect via the socket.io client library like this:

var socket = io('/customer-support/chat');
console.log(socket.id);

var self = this;
socket.on('connect', function() {
  console.log('connected!');
  console.log(socket.id);
});

Expected behavior

The client side app should successfully connect via a socket over the desired path. That desired path is /customer-support/chat

Actual behavior

The client side app never connects to the server.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):
feathers-socketio: "2.0.0"

NodeJS version:
v.6.9.4

Operating System:
WIndows 10

Browser Version:
Google Chrome

React Native Version:
N/A

Module Loader:
N/A

@daffl
Copy link
Member

daffl commented Jun 15, 2017

Are you sure Socket.io paths is what you are looking for? To me this seems like two separate services that you then connect to via Feathers on the client.

As it stands right now you are not using any of Feathers functionality which you can of course do but it kind of defeats the purpose 😉 I recommend to go through the chat guide to get an idea how all those things fit together.

@daffl daffl closed this as completed Jun 21, 2017
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants