-
Notifications
You must be signed in to change notification settings - Fork 241
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
implement websocket client #57
Comments
Any thoughts on aleph-based SockJS server and/or client implementations? There's already a test suite for the SockJS protocol: https://github.com/sockjs/sockjs-protocol That could act as a nice guide for building such implementations, in addition to testing them. But do you think aleph is well suited for this purpose? The vert.x folks have implemented a SockJS server in Java (example usage), and it could likely be imported and used in a Clojure project without too much trouble. But perhaps there would be some advantages to an aleph-based implementation? One of the nice things about SockJS is that a proper client can be used with a plain websocket server; likewise, a SockJS server can be used by a plain websocket client. But the same client and server can also use the non-websocket transports, preserving the same higher-level API, if the other party doesn't support websocket. |
I should close this issue since there is a websocket client now, but while we're on the subject: I've been meaning to put together a socket.io implementation for a bit, since that seemed to be the predominant implementation, but I'm by no means an expert in the various protocols floating around. Am I wrong to be conflating SockJS and socket.io? If not, what are the trade offs between the two? |
I'm not an expert either, but from hunting around in Google Groups and on blogs, etc. it seems that socket.io is actually rather difficult to implement correctly (and with good performance) given the complexity of the API as it developed over time. In response to the growing complexity, SockJS was developed as an alternative, and it's now a fairly well advanced polyglot initiative. There's some good info here: https://github.com/sockjs/sockjs-client Long story short, SockJS focuses on creating a uniform socket-like API abstraction on top of the various transports, and that's it. Socket.io goes further and implements an API for things like acknowledgements and broadcasts. While those things are useful, that's where the complexity comes in. The socket.io team seems to have recognized these problems and there is a derivative project called engine.io: https://github.com/LearnBoost/engine.io If I understand correctly, engine.io is supposed to eventually become a dependency of socket.io, providing the lower-level abstractions (i.e. the cross-transport socket-like API). The more complex parts of socket.io can then exist as a layer built on top of engine.io. |
There are number of "socket.io vs sockjs" threads and blog posts out there, but I thought this one was pretty interesting, just took me a few minutes to find it again: https://groups.google.com/forum/#!msg/sockjs/WSIdcY14ciI/B9kot6nS73MJ |
Thanks. Like I said, I've been meaning to do something like this for a bit, and I appreciate you bringing the alternative protocol to my attention. I'm going to close this issue, but rest assured that this is near the top of my todo list. |
Pardon my confusion, but wasn't websocket-client implemented 5 months ago in https://github.com/ztellman/aleph/blob/perf/src/aleph/http/websocket.clj ? |
Yes, which is why I closed the issue (I forgot it was here until just now). Everything discussed here is about something else entirely. |
That's what I thought, but wasn't sure. Hope you won't mind, then, if I ask about use examples within a 'lein test' or 'lein midje' context; I've spent the last few days trying to test websockets in my Aleph/Compojure application, and am at a bit of a loss. Was hoping I'd see you in #clojure on IRC; my queries about it the last hour have drawn zero interest from the gallery... |
I'm assuming you've seen https://github.com/ztellman/aleph/blob/perf/test/aleph/test/websocket.clj ? I know it's a bit sparse, I'm happy to answer any specific questions you might have. |
Yes, I've seen it, thanks; I was hoping to find examples with more options than simply :url. But I'll revisit the example here - thanks again for reminding me of it - and see how far I can go with it. |
There aren't really any other options than |
Awesome. You rock, thanks for your help. |
potentially useful in the real world, but necessary for automated testing of the websocket functionality
The text was updated successfully, but these errors were encountered: