meteor-feature-requests icon indicating copy to clipboard operation
meteor-feature-requests copied to clipboard

Replace SockJS with something that works better in non-browser environments

Open benjamn opened this issue 8 years ago • 9 comments

Migrated from: meteor/meteor#8621 Related: #27


@hwillson in meteor/meteor#8621:

As part of the Meteor support for non browser environment discussions in #8615, it was suggested (and PR encouraged) that a replacement for SockJS should be found (if possible/advantageous). Since there will likely be a lot of discussion about a potential replacement, I'm creating this new issue to track that work (and to make sure the other items in #8615 aren't drowned out).

One thing to note - finding a SockJS replacement will impact several other open issues. I'll list them here to make sure anyone thinking about working on those issues is given a heads up about a potential replacement.

Open SockJS (related) issues: #1285, #4114, #4897, #6389, #6719, #8254, #8317

Relevant bits extracted from #8615:

(from https://github.com/meteor/meteor/issues/8615#issuecomment-295925903)

Replace SockJS with something that works better in non-browser environments. Unfortunately, socketio-1.7.2.js is much larger than sockjs-0.3.4.js (159KB vs 78.3KB), and I don't think we can justify increasing the size of ddp-client by that much. Could we use something smaller, like https://www.npmjs.com/package/ws, instead?

In particular, we would be happy to review a pull request to replace SockJS with a smaller library, since that fits nicely into #8327.

(from https://github.com/meteor/meteor/issues/8615#issuecomment-295960575)

As far as I know WS doesn't use polling, only WebSockets, so I wouldn't consider it to be the ideal solution.

benjamn avatar Jun 07 '17 13:06 benjamn

I see SockJS as a polyfill for websockets. Instead of replacing it, I think it would be better if we just extend the polyfill with support for other options.

What exactly are issues with SockJS for non-browser environments?

mitar avatar Jun 07 '17 18:06 mitar

Some arguments against socket.io and for sock.js: https://github.com/rethinkdb/horizon/issues/413

mitar avatar Jun 07 '17 18:06 mitar

Please see https://github.com/meteor/meteor-feature-requests/issues/116. If SockJS is import-able, then adding a transport is usually not difficult, and I have done so in several non-browser environments (with Meteor) including Atomic Game Engine. I just had to hack the files to make SockJS a global.

Type1J avatar Jun 15 '17 20:06 Type1J

Any updates?

maxpain avatar Mar 11 '18 17:03 maxpain

I haven't upgraded my hacked version in a while. I believe it probably still isn't exposed.

Type1J avatar Mar 12 '18 18:03 Type1J

Why is Meteor still using 0.3.4 of SockJS, could we at least update it to a more recent version?

For example, the ability to add query strings to SockJS URLs has been supported for 4 years, but with Meteor you still can't use it.

Is this a difficult migration?

Floriferous avatar Jul 05 '19 09:07 Floriferous

@benjamn is this repo still the correct place to discuss this?

perbergland avatar Oct 06 '19 07:10 perbergland

@perbergland Yes

StorytellerCZ avatar May 11 '21 17:05 StorytellerCZ

Just an update, linking here some recent PR related to SockJS: https://github.com/meteor/meteor/pull/11416

StorytellerCZ avatar May 11 '21 17:05 StorytellerCZ