joncursi / socket-io-client Goto Github PK
View Code? Open in Web Editor NEWA Meteor wrapper for the NPM socket.io-client binary package
A Meteor wrapper for the NPM socket.io-client binary package
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
Exception from Tracker recompute function: undefined
meteor.js?hash=ae8b8af…:932 ReferenceError: io is not defined
at ChatBox.componentDidMount (http://localhost:3000/app/app.js?hash=d41b1979c9e13bc17f898559c3df566ef9b53f72:3611:20)
at http://localhost:3000/packages/modules.js?hash=f8927eac55e1af839abf7d49f70b76b9e3d329f8:16392:25
at measureLifeCyclePerf (http://localhost:3000/packages/modules.js?hash=f8927eac55e1af839abf7d49f70b76b9e3d329f8:16202:12)
at http://localhost:3000/packages/modules.js?hash=f8927eac55e1af839abf7d49f70b76b9e3d329f8:16391:11
at CallbackQueue.notifyAll (http://localhost:3000/packages/modules.js?hash=f8927eac55e1af839abf7d49f70b76b9e3d329f8:9087:22)
at ReactReconcileTransaction.close (http://localhost:3000/packages/modules.js?hash=f8927eac55e1af839abf7d49f70b76b9e3d329f8:18997:26)
at ReactReconcileTransaction.closeAll (http://localhost:3000/packages/modules.js?hash=f8927eac55e1af839abf7d49f70b76b9e3d329f8:10243:25)
at ReactReconcileTransaction.perform (http://localhost:3000/packages/modules.js?hash=f8927eac55e1af839abf7d49f70b76b9e3d329f8:10190:16)
at ReactUpdatesFlushTransaction.perform (http://localhost:3000/packages/modules.js?hash=f8927eac55e1af839abf7d49f70b76b9e3d329f8:10177:20)
at ReactUpdatesFlushTransaction.perform (http://localhost:3000/packages/modules.js?hash=f8927eac55e1af839abf7d49f70b76b9e3d329f8:8849:38) undefined
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.
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.
I took a look at your code.There is api.export(io)
But still io is 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
Hi!
I have the following issue that i have resolved, but still would like to put it here for 2 reasons:
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
).
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!
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!!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.