Is there anything in Meteor.bindEnvironment which would cause "slow" callbacks?


Here is my basic package code, where I open two TCP sockets.

// server.es6
Galil._createConnection = function (name) {
  check(name, String);
  Galil.connections.upsert({ name: name }, {
      $set: { status: 'disconnected' },
      $setOnInsert: { messages: [] }
  let socket = net.connect(Galil.config.connection, Meteor.bindEnvironment(function () {
    Galil.connections.update({ name: name }, { $set: { status: 'connected' } });
  let setDisconnected = function () {
    Galil.connections.update({ name: name }, {
      $set: { status: 'disconnected' }
  socket.addListener('end', Meteor.bindEnvironment(setDisconnected));
  socket.addListener('close', Meteor.bindEnvironment(setDisconnected));
  socket.addListener('error', Meteor.bindEnvironment(setDisconnected));

So in my hardware controller, I try unplugging it. I expect that this will cause the collection to update and set to disconnected. However, if it does, it takes a pretty considerable amount of time. Has anyone experienced this? What do?


What do you mean by hardware controller disconnected?


It’s plugged in via an ethernet cable. I try removing the ethernet cable.


Ethernet is designed to combat latency. It can take up to 10 seconds after unplugging an Ethernet cable for your computer to realise. Try disabling your network controller directly, that should happen faster.