I have an IoT device that will eventually have thousands connected to our Meteor server and I am trying to figure out the best way to connect.
I see two different ways. There is the sockjs url (sockjs/serverId/sessionId/websocket) or just a normal websocket (/websocket)
So I am trying to figure out which is the better one to use.
From my investigation /websocket is the cleanre interface and involves less communication, but the /sockjs seems like it has more bells and whistles that will help load balancing the server.
Do I understand the sockjs url enough that it would help a service like heroku keep session affinity and with load balancing? Or is that also taken care of by the /websocket url?
Also is sockjs likely to be removed from Meteor? I don’t want to implement something that will be removed in the future.
I’m trying to figure out what is the best way to make sure that this is very scalable, but I need a bit more info than I can easily find.
Do you really need sockets at all ?
Maybe a REST API would be best, less server load, less energy consuming for the devices.
If sockets are needed why not use ddp ?
Load balancing should be handled by a reversed proxy (such as nginx).
Yes my use case needs instant feedback from the arduino so it does require a websocket connection.
DDP is just a wrapper around sockjs/native websocket so its not really relevant.
So my question is what is better for the server, sockjs or native websocket. Sockjs has unique urls that may allow heroku to handle it better as we grow, but native Websocket is just less communication (by like 5% so not super important)
So the question is does sockjs provide any extra benefit to the server, or is it just a way to abstract the api so we can use long polling in older browsers?
There was a discussion to upgrade the sockjs version being used by Meteor because it wasn’t updated for years now
from the device, a rest api can still handle this
Oh sorry did mean that.
needs instant feedback from the server
But it sounds like if sockjs is being abandoned, websocket is just safer to use. Thanks
Here is the relevant discussion
Sockjs is used for all websocket connections in meteor. It promises to provide a http fallback in cases where native websockets don’t work.
The current sockjs implementation was copy-forked (the library source code was copied into meteor) in 2012 using version 0.3.4 of sockjs and after that the
real sockjs library has evolved to version 1.4.0 while the copied code also received changes that were the reason to fork the code way back.
There are known bugs like this one and no one ha…