Closed seiyria closed 9 years ago
@seiyria In your console do:
npm remove -g socketcluster
then
npm cache clean
Then follow these steps exactly: http://socketcluster.io/#!/docs/getting-started
@seiyria Did you run the socketcluster create myappname
command afterwards?
@jondubois No, I ran that to generate the project shown above, then I removed the server / serve-static part of it as this will just be a dedicated backend (the frontend is an app).
@seiyria So you don't want SC to serve the client file (socketcluster.js) - You want to serve it from somewhere else?
@jondubois Yes, I was under the impression that it was a client and the client could be served from anywhere else. Based on your reaction, I suspect that won't work so well. I suppose I could serve just the js file from there and have the app include it, but I prefer to not have external assets (I think Apple has a policy against that, so my app would probably get rejected).
That is possible - You can get the client separately and serve it up from anywhere, but it's a bit trickier to setup (manual). Did you use the socketcluster.js file that is inside socketcluster-client/ repo?
Yeah, I've tried that as well. My basic code to reproduce was above. It didn't seem to establish a connection.
@seiyria Note sure if that could explain the problem but I noticed that there was an outdated socketcluster.js client inside the socketcluster/sample/ app - This was an accident - I removed that file from the module on npm. You should only use the one from the https://github.com/TopCloud/socketcluster-client repo.
Absolutely, that's the one I was using.
What OS are you using?
I'm on OSX for dev. Originally, I tried hosting the server on my linux VM on my windows machine across the network, but I eventually moved it all to my OSX machine to eliminate possible network problems as a cause (though once I have something working I will revisit getting that working).
Is your HTTP server running on the same host/domain as the socketcluster server?
Yes, currently it is. I'm trying to establish the connection via localhost:8000
.
What do you get when you run socketcluster -v
?
Oh, wait, shoot. Something I'll have to take a look at later, actually, I don't think it is. It's running in the iOS simulator, which simulates a device. localhost
would probably refer to that device, not the host machine. That doesn't explain why it couldn't connect when given a specific IP, though.
Sorry, this might be a total non-issue; I didn't even think about that. I'll try to resolve this when I'm at my machine next.
Thanks for your support so far!
Ok. Let me know. Thanks for reporting. If in doubt, raise an issue :)))
Hey, so I double checked. Apparently iOS simulator uses the host network, ie, localhost
definitely refers to the machine currently running the server.
So you didn't manage to get it working on any platform? Did you try to run on Windows directly?
It would be interesting to know what's causing this. I might play around with serving the file from a different origin than the SC server just to see what happens - This should be supported by default though.
I have not (I actually have no development tools available to me on windows by design).
It'd be difficult for me to run it all in just linux, as well, as I was unable to get the android simulator working and I can't get the ios simulator on it, so that unfortunately leaves me stuck on OSX. My project is an Ionic app, I should also add. I don't know if that makes a difference though.
Sure, I mean if it works for you, I'm probably screwing something up, but .. who knows.
@seiyria I noticed in your first post, you mentioned an 'xhr poll' error - This suggests that you are using version 1.x.x of the client and not the latest 2.x.x version. Could you be using the SC1 client with the SC2 server? The two versions have the same external API but are protocol-incompatible.
Unfortunately, the version number isn't anywhere in the client script (yet) - But to check you can open the socketcluster.js client file and search for the string 'engine.io' - If there are any matches, then it means that you are using v1 of the client.
If that's the issue, make sure you do npm cache clean
and then npm install socketcluster-client
then get the socketcluster.js file from there - This will be version 2.
npm packages and git branches for SC1 and SC2 have moved around about one or two weeks ago so this could have caused cache issues with npm.
Maybe that's the issue.
Absolutely, thank you. I will give this a try when I get back and let you know the results. I was out of ideas!
Ah, I figured out why. I bower installed your repo, but you never pushed tags to it, so I got 0.9. I'll try now and see if it works!
Yep, and it definitely works now! Thanks for pointing that out. When you attend to #7, make sure you push all your tags :P
Thanks a ton!
This is probably me doing something dumb, but I'm unable to get this working on the client. What I did:
npm install socketcluster-client
cd node_modules/socketcluster-client
browserify -s socketCluster index.js > socketcluster.js
and include that file.
I've also tried just using the socketcluster.js file from the repo, but that seems to fail when I attempt to use the socket like so:
And in my server:
But I get nothing in my browser console, except eventually, I get an xhr polling error. Not sure how to get started with this.