Git Product home page Git Product logo

Comments (12)

michaelsbradleyjr avatar michaelsbradleyjr commented on May 19, 2024

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.

from aleph.

ztellman avatar ztellman commented on May 19, 2024

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?

from aleph.

michaelsbradleyjr avatar michaelsbradleyjr commented on May 19, 2024

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.

from aleph.

michaelsbradleyjr avatar michaelsbradleyjr commented on May 19, 2024

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

from aleph.

ztellman avatar ztellman commented on May 19, 2024

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.

from aleph.

russellwhitaker avatar russellwhitaker commented on May 19, 2024

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 ?

from aleph.

ztellman avatar ztellman commented on May 19, 2024

Yes, which is why I closed the issue (I forgot it was here until just now). Everything discussed here is about something else entirely.

from aleph.

russellwhitaker avatar russellwhitaker commented on May 19, 2024

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...

from aleph.

ztellman avatar ztellman commented on May 19, 2024

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.

from aleph.

russellwhitaker avatar russellwhitaker commented on May 19, 2024

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.

from aleph.

ztellman avatar ztellman commented on May 19, 2024

There aren't really any other options than :url. The handshake is automatic, and everything else is what you do once you get the websocket channel.

from aleph.

russellwhitaker avatar russellwhitaker commented on May 19, 2024

Awesome. You rock, thanks for your help.

from aleph.

Related Issues (20)

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.