Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'connectionRetry' was not trigger #46

Open
JasLin opened this issue Jun 14, 2018 · 0 comments
Open

'connectionRetry' was not trigger #46

JasLin opened this issue Jun 14, 2018 · 0 comments

Comments

@JasLin
Copy link

JasLin commented Jun 14, 2018

hi @alaa-eddine

I am trying 001-http-server examples, 'connectionRetry' was not trigger.

client code

var Eureca = require('eureca.io');

var client = new Eureca.Client({ uri: 'ws://localhost:8000/' , timeout:1000, pingTimeout:1000});

client.onError((e) => {
    console.error('an error raise: ', e)
  })
  
  client.onConnect((conn) => {
    console.log('new Client', conn)
  })
  client.onMessage((msg) => {
    console.log('recv msg: ', msg)
  })
  client.onDisconnect((conn) => {
    console.log('Client disconnect', conn)
  })
  
  client.onConnectionLost((conn) => {
    console.log('connection lost', conn)
  })
  
  client.onConnectionRetry((conn) => {
    console.log('connection retrying', conn)
  })
  
client.ready(function (proxy) {

    proxy.hello();

});

server code:

var http = require('http');
var fs = require('fs');

var server = http.createServer();

var Eureca = require('eureca.io');

var eurecaServer = new Eureca.Server();

eurecaServer.attach(server);

//functions under "exports" namespace will
//be exposed to client side
eurecaServer.exports.hello = function () {
    
    console.log('Hello from client');
}


server.on('request', function (request, response) {
    var i;
    
    if (request.method === 'GET') {
        
        if (request.url.split('?')[0] === '/') {
            var filename = __dirname + '/index.html';
            fs.readFile(filename, function (err, data) {
                var text = data.toString();
                response.writeHead(200, { 'Content-Type': 'text/html' });
                response.write(text);
                response.end();
            });
        }
    }

});



console.log('\033[96mlistening on localhost:8000 \033[39m');
server.listen(8000);

server out:

eureca.io v0.8.1
listening on localhost:8000
Hello from client

client out:

eureca.io v0.8.1
ws://localhost:8000/ eureca.io
new Client Socket {
  socket:
   Primus {
     _events:
      { 'outgoing::open': [Array],
        'incoming::open': [Function: opened],
        'incoming::ping': [Function: ping],
        'incoming::error': [Function: error],
        'incoming::data': [Function: message],
        'incoming::end': [Function: end],
        'outgoing::data': [Function: write],
        'outgoing::reconnect': [Function: reconnect],
        'outgoing::end': [Function: close],
        open: [Array],
        data: [Function],
        end: [Array],
        error: [Array],
        reconnecting: [Function] },
     _eventsCount: 14,
     _maxListeners: undefined,
     buffer: [],
     writable: true,
     readable: true,
     url:
      { slashes: true,
        protocol: 'ws:',
        hash: '',
        query: '',
        pathname: '/',
        auth: '',
        host: 'localhost:8000',
        port: '8000',
        hostname: 'localhost',
        password: '',
        username: '',
        origin: 'ws://localhost:8000',
        href: 'ws://localhost:8000/' },
     readyState: 3,
     options:
      { queueSize: Infinity,
        timeout: 10000,
        reconnect: {},
        pingTimeout: false,
        strategy: 'disconnect,online,timeout',
        transport: [Object] },
     timers: Tick { timers: [Object], context: [Circular] },
     socket:
      Socket {
        secure: false,
        agent: false,
        hostname: 'localhost',
        port: 8000,
        query: [Object],
        upgrade: true,
        path: '/eureca.io/',
        forceJSONP: false,
        jsonp: true,
        forceBase64: true,
        enablesXDR: false,
        timestampParam: 't',
        timestampRequests: true,
        transports: [Array],
        transportOptions: {},
        readyState: 'open',
        writeBuffer: [],
        prevBufferLen: 0,
        policyPort: 843,
        rememberUpgrade: false,
        binaryType: null,
        onlyBinaryUpgrades: undefined,
        perMessageDeflate: [Object],
        pfx: null,
        key: null,
        passphrase: null,
        cert: null,
        ca: null,
        ciphers: null,
        rejectUnauthorized: true,
        forceNode: false,
        id: 'S-rgDVndlGJHCMkJAAAA',
        upgrades: [Array],
        pingInterval: 25000,
        pingTimeout: 5000,
        pingIntervalTimer: null,
        pingTimeoutTimer: null,
        transport: [XHR],
        _callbacks: [Object] },
     disconnect: false,
     transport:
      { slashes: true,
        protocol: 'http:',
        hash: '',
        query: '_primuscb=MFt8OAq',
        pathname: '/eureca.io',
        auth: '',
        host: 'localhost:8000',
        port: 8000,
        hostname: 'localhost',
        password: '',
        username: '',
        origin: 'ws://localhost:8000',
        href: 'ws://localhost:8000/',
        object: true,
        secure: false,
        rememberUpgrade: false,
        forceBase64: true,
        enablesXDR: false,
        timestampRequests: true,
        path: '/eureca.io',
        transports: [Array] },
     transformers: { outgoing: [], incoming: [] },
     recovery:
      Recovery {
        attempt: null,
        _fn: null,
        'reconnect timeout': 30000,
        retries: 10,
        factor: 2,
        max: Infinity,
        min: 500,
        timers: [Tick],
        _events: [Object] } },
  eureca: {},
  request: undefined,
  id: [Function: id],
  remoteAddress: undefined,
  _proxy: {},
  _events:
   { open: [ [Function] ],
     message: [ [Function] ],
     reconnecting: [ [Function] ],
     close: [ [Function] ],
     error: [ [Function] ],
     stateChange: [ [Function] ] } }
recv msg:  { __eureca__: [ 'hello' ] }
recv msg:  { s: 'ohwVjK4cgV', e: null }

then I shutdown server. there is no connectionRetry event trigger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant