Comments (4)
Given the user could connect to another server, I would expect it could very easily be different, yes. Have you tested it out?
from docs.
Doh. I was thinking this section of the docs was server-side. Definitely don't want to give the impression the idString
is reused when connecting to different servers.
I take it an admin can use multiple Meteor servers in a load-balancing fashion, where reconnections may shift to a server with less load? I figured if a user connects to a server, loses the connection, and the client app reconnects, the client would select the same server from before.
I'm particularly interested in whether tracking connections on the server is possible in case users of publish-counts decide they want to manage the handles from Counts.publish
and call handle.stop()
when invoking a second subscription to avoid collisions.
I haven't tested, but will give it a go and report back.
from docs.
Finally got around to testing it out. Started out with no time, completely forgot about this, then remembered I left this lying around today.
So.
Test 1.
What if the user disconnects the app through Meteor.disconnect()
and then uses Meteor.reconnect()
?
I created a new Meteor 1.4.0.1 app for testing. Added two buttons to the client's page. Click one to disconnect with Meteor.disconnect()
, click the other to reconnect with Meteor.reconnect()
. Also display Meteor.status().status
on the page to observe connection status. On the server, a Meteor.onConnection
handler dumps the connection.id
string to the console.
// server/main.js
import { Meteor } from 'meteor/meteor'
Meteor.startup(() => {
Meteor.onConnection(connection => console.log(connection.id))
})
cd <meteor app folder>
- run
meteor
to start app. - open
http://localhost:3000
to view app.
- note the client status is
connected
.
- check server console.
- note that a
connection.id
string is printed.
- disconnect the client by clicking the disconnect button.
- note the client status is
offline
.
- reconnect the client by (you guessed it) clicking the reconnect button.
- note the client status is
connected
- note the server console shows a new-and-unique connection id string, unlike the first id string.
Conclusion:
the connection id string is always new and unique, even when the same client reconnects using Meteor.reconnect()
.
Test 2.
What if a network error disconnects the client and automatically restores later?
For this test, I reused the same test app from Test 1 along with some iptables
-fu to simulate a network outage by dropping packets heading to the server, then later allowing packets to reach the server.
cd <meteor app folder>
- run
meteor
to start app. - open
http://localhost:3000
to view app.
- note the client status is
connected
.
- on the server, run the command from a bash shell to simulate a network failure...
sudo iptables -I INPUT 1 -p tcp -d 127.0.0.1 --dport 3000 -j DROP
- note that the client status switches to
waiting
andconnecting
after a few (<20) seconds. - wait for the client status to change from
connected
before continuing.
- on the server, run the command from a bash shell to restore the network...
sudo iptables -R INPUT 1 -p tcp -d 127.0.0.1 --dport 3000 -j ACCEPT
- note that the client status switches to
connected
after a few (<20) seconds. - note the server console shows a new-and-unique connection id string, unlike the first id string.
- remove the
iptables
rule.
sudo iptables -D INPUT 1
Conclusion
the connection id string is always new and unique, even when the same client reconnects automatically after a network error.
Epilogue
I think it's safe to say that a new id
(aka idString
in OP) is created every time any client connects. This is consistent with the close
documentation below id
.
closeFunction
Close this DDP connection. The client is free to reconnect, but will receive a different connection with a new id if it does.
This answers my question. Not sure if there's any need to update the docs. Will let you have the final word @tmeasday. Close at your convenience.
Cheers.
from docs.
(Prologue: The confusing idString
was a graphical error in the docs theme which was causing the field name and type to be smashed into each other and displayed confusingly. The docs now properly separate this. 😉)
I think the keyword is connection
in A globally unique id for this connection.
: When a connection is broken for any reason, a new connection is made and the id
is regenerated.
from docs.
Related Issues (20)
- Upsert documentation is misleading HOT 4
- Implementing Accounts Without Wrapping a Blaze component in React HOT 1
- Question: Use fork or local clone as the source for /code? HOT 2
- deploy/netlify PR check broken HOT 1
- Docs show 1.8 as latest version HOT 5
- CLI docs are missing --mobile-settings option for build
- Docs for v1.8 not available HOT 1
- No meteor typescript documentation HOT 2
- Add meteor publish --update to the docs HOT 4
- changes appears twice in v1.9 change log
- create basic documentation for the Accounts.createUserVerifyingEmail function HOT 2
- meteor create command is still not updated HOT 1
- Dynamic import cors issue and fix not documented HOT 1
- CSP Helmet example needs to cover hashes for modern and legacy bundles
- Document --exclude-archs flag
- Meteor commands are not orderd alphabetically HOT 1
- Meteor v2.2 API docs not available (404) HOT 2
- Cannot navigate back to new API docs from older API docs HOT 5
- Logo messed up when navigating directly to older versions of the docs HOT 2
- password_server methods documentation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.