Skip to content

Delay in triggering the function emit. #36

@valentineus

Description

@valentineus

There is a noticeable delay before which the Streamy.emit function begins to work.
Why does this occur and how to fix it?

Example

Client side code:

Streamy.onConnect(() => console.log('Connection completed successfully.'));
Streamy.onDisconnect(() => console.log('There was a disconnection from the server.'));
Streamy.emit('test', { data: 'Hello, World!' });

Server side code:

Streamy.onConnect((socket) => console.log('Connected:', Streamy.id(socket)));
Streamy.onDisconnect((socket) => console.log('Disconnected:', Streamy.id(socket)));
Streamy.on('test', (data, from) => console.log(data));

There is a message from the client about the successful connection, there are no other messages.

Server-side command line:

Meteor
[[[[[ ~/workspace/streaming ]]]]]             

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: https://<hostname>
I20170530-19:20:21.075(3)? Connected: cg9FKWWBQcThKM5eF


Process exited with code: 0

Detecting the delay

Client side code:

var i = 0;
Meteor.setInterval(function() {
    Streamy.emit('test', {
        data: 'Hello, World!',
        timer: i++
    });
}, 3000);

Server-side command line:

Meteor
[[[[[ ~/workspace/streaming ]]]]]             

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: https://<hostname>
I20170530-19:28:31.493(3)? Connected: G4Ts8HtiDs7MftDuQ
I20170530-19:28:33.639(3)? { data: 'Hello, World!', timer: 14 }
I20170530-19:28:36.639(3)? { data: 'Hello, World!', timer: 15 }
I20170530-19:28:39.639(3)? { data: 'Hello, World!', timer: 16 }


Process exited with code: 0

Working environment

An empty project created with the --bare option and remote dependencies for front-end development is used.

$ meteor --version
Meteor 1.4.4.3
$ cat ./.meteor/packages 
meteor-base@1.0.4
mobile-experience@1.0.4
mongo@1.1.17
ecmascript@0.7.3
shell-server@0.2.3
static-html@1.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions