What's the correct way of using Socket.io with Meteor?

Hey all,

Need a little advice on using Socket.io with Meteor.

I have an existing Node.js project that has two components.

  • (Client) HTML page which has a simple upload form and establishes a Socket.io connection to the Node.js API
  • (Server) Node.js API which receives uploaded images/videos and broadcasts over Socket.io whether the upload and/or processing has been successful, with a accompanying link to the processed files upon completion. (This will sit on a separate server.)

I’d like to bring the client portion of the existing project into Meteor and have it sit behind a user login, as well as have Meteor handle success/failure depending on a Socket.io broadcast.

Basically:

  1. Client uploads images/video via upload form
  2. Server receives images/video and processes them
  3. Server broadcasts via Socket.io success or failure
  4. (On success) Client receives broadcast via Socket.io and creates a new document in a collection, as well as notifies user of success.
  5. (On failure) Client receives broadcase via Socket.io notifies user of failure and asks user to re-upload files.

So the question is, what’s the correct way of implementing Socket.io and the client in Meteor? :smile:

Hey, how did this work out?

I’m looking at a similar situation, integrating a Socket.io component into Meteor.

I haven’t found a good solution, but these links were interesting:


https://github.com/Lepozepo/meteor-streams/ - fork of abandoned project
https://github.com/RocketChat/Rocket.Chat/issues/254

I’m thinking of simulating Socket.io with a hacked Meteor-EventDDP. Any other suggestions?

checkout Streamy :



good if you need basic websocket message chat-style functionality, and you don’t want to store the messages in the database.

In the above use case for getting the status of an upload, I would just use Meteor’s pub / sub as it is. I would suggest to insert an Upload Document into the database when the upload starts, not after it succeeds. If the upload fails the server can set a property on the Mongo Document and the client will be notified via pub / sub ‘changed’ which will occur on the Document.

Looking into this as well. Can socket.io be integrated with Meteor like we integrate socket with Express?