Jankapunkt
Jankapunkt

Reputation: 8423

Meteor detect on client load if web socket connection failed

Is there a way to detect if the current client web socket connection has failed without installing extra tools, such as wscat?

In my case after a restart of my production app the first connection attempt fails to connect to the web socket, but a page reload does it.

In this case I would force my client to reload in order to regain a running web socket connection.

Upvotes: 0

Views: 301

Answers (1)

Mikkel
Mikkel

Reputation: 7777

Have a look at https://docs.meteor.com/api/connections.html

There is a method Meteor.status() which runs on the client and is a reactive data source, which means you can use it in a template or computation to get realtime updates.

If you detect a failure you shouldn't do anything straight away, most times the connection will automatically recover. You should wait a few seconds before taking action (like a refresh)

Upvotes: 1

Related Questions