Coder Social home page Coder Social logo

socket-io-client's People

Contributors

joncursi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

socket-io-client's Issues

can i connect to ws://socketserver ?

hello iḿ trying but cannot connect to my server

I have a normal webpage that connects like this

web2py_websocket('ws://serverip:12200/realtime/mygroup1')

trying to connect using your package does not do anything

this is my code using your package to mimic my previous code...
var socket = io('ws://serveip:12200/realtime/');

// subscribe to a data feed
socket.emit('subscribe', 'mygroup1');

are they equivalent ?

should i replace ws with http?

regards

ReferenceError: io is not defined

Please publish your package joncursi:socket-io-client for Windows

Hi!

This package has binary dependencies, and we wanted to give you a heads up that Meteor 1.1, with support for Windows will be released in a few days.

Now is the time to publish your package for Windows!

It should be very straightforward -- we've added new build machines that run Windows that you can access with the meteor admin get-machine command. This is the same as you've done before for the other architectures we support.

For complete directions on how to publish your package for Windows, visit https://github.com/meteor/meteor/wiki/Publishing-a-package-with-binary-dependencies-for-the-Windows-preview

On behalf of the Meteor team,
@stubailo, @Slava and @avital.

P.S. This is an automated message based on our database of package authors.

io is undefined in package

I am trying to use this package as dependency for my package

  var packages = [
        'ecmascript',
        'joncursi:socket-io-client'
    ];

    api.use(packages);

Trying to use in my package file as
import io from 'meteor/joncursi:socket-io-client'

When I debugged in chrome inspector as I was running tests for my package.
screenshot from 2016-12-23 14 15 36

I took a look at your code.There is api.export(io)
But still io is undefined

Cannot read property 'protocol' of undefined

Hey,

I am trying to connect to some Slack Websocket var url = wss://ms122.slack-msgs.com/websocket/LONG_STRANGE_ID

in my code I do

        var socket = io(url);
        socket.on('connect', Meteor.bindEnvironment(function() {
          console.log('Connected to the websocket!');
          // on data event
          socket.on('hello', Meteor.bindEnvironment(function(data) {
            console.log(data);
          }, function(e) {
            throw e;
          }));

        }, function(e) {
          throw e;
        }));

but it throws

Exception in callback of async function: TypeError: Cannot read property 'protocol' of undefined
  at url (/Users/picsoung/.meteor/packages/joncursi_socket-io-client/.0.1.4.17780oj++os+web.browser+web.cordova/npm/node_modules/socket.io-client/lib/url.js:29:29)
  at lookup (/Users/picsoung/.meteor/packages/joncursi_socket-io-client/.0.1.4.17780oj++os+web.browser+web.cordova/npm/node_modules/socket.io-client/lib/index.js:44:16)
   at app/methods/method.slack.js:11:22
  at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)

any idea how I can solve this?
Thanks

Web socket connection not receiving data after re-connect

Hi!

I have the following issue that i have resolved, but still would like to put it here for 2 reasons:

  1. I would like to know if this is a bug or it's supposed to work like this.
  2. To help anyone who chance upon this problem in future.

Problem:

getSensorDataWebSoc: function(deviceModel,deviceUUId,deviceSensors) {
        if(!socket){
            socket = io('https://websocket.btcchina.com/');
            socket.emit('subscribe', 'marketdata_cnybtc');
            socket.on('connect', Meteor.bindEnvironment(function() {
                socket.on('trade', Meteor.bindEnvironment(function(data) {
                   console.log(data);
                  }, function(e) {
                    throw e;
                  }));
                  socket.on('disconnect', Meteor.bindEnvironment(function() {
                    console.log('Disconnected from the websocket!');
                  }, function(e) {
                    console.log("in disconnect fail " + e);
                    throw e;
                  }));
                }, function(e) {
              console.log("inside connection fail");
                  throw e;
                }));
        } else {
            console.log("socket existed");
            socket.connect();
        }   
 },
closeWebSoc: function(){
    socket.disconnect(true);
},

I have the above code placed inside Meteor.methods. It's a very standard web socket connection, and i'm listening on the trade event. What i realised is that once i called the closeWebSoc function when i leave a template, and re-enter the template again, i won't be receiving any data anymore. The same result applies even after i refresh the page, close the browser and re-open the meteor app. The only 'fix' to get back my connection with data streaming in is to restart the meteor app.

After hours of debugging, i realised that the problems comes from socket.emit. Apparently, after reconnecting, the socket object does not contain the object holding those variables (as seen from socket.sendBuffer[0].data).

Solution:

To solve that issue is actually quite simple: we simply re-emit the subscribe again before we run the connect:

getSensorDataWebSoc: function(deviceModel,deviceUUId,deviceSensors) {
        if(!socket){
            socket = io('https://websocket.btcchina.com/');
            socket.emit('subscribe', 'marketdata_cnybtc');
            socket.on('connect', Meteor.bindEnvironment(function() {
                socket.on('trade', Meteor.bindEnvironment(function(data) {
                   console.log(data);
                  }, function(e) {
                    throw e;
                  }));
                  socket.on('disconnect', Meteor.bindEnvironment(function() {
                    console.log('Disconnected from the websocket!');
                  }, function(e) {
                    console.log("in disconnect fail " + e);
                    throw e;
                  }));
                }, function(e) {
              console.log("inside connection fail");
                  throw e;
                }));
        } else {
            console.log("socket existed");
            socket.emit('subscribe', 'marketdata_cnybtc');//new line added to make it work.
            socket.connect();
        }   
 },
closeWebSoc: function(){
    socket.disconnect(true);
},

and viola! Now the connection works as expected.

Any idea if this is the intended work flow to use or is this a bug of the code?
Thank you!

Use socket-io-client to connect serverSide with nodeJS server

Hi,
I'm testing socket-io-client to connect meteor with NodeJS server, but I cant achieve that my meteor server connect with my Node server.
I declare my socket:
socket = io(IP_NODE);

I emit a message,
socket.emit('register', {
name : userName,
age : userAge
});
but in node server doesnt see anything.
¿What is wrong?

Thanks!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.