Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket closing without prompt #321

Open
CarolineBoyer opened this issue Nov 10, 2021 · 0 comments
Open

Socket closing without prompt #321

CarolineBoyer opened this issue Nov 10, 2021 · 0 comments

Comments

@CarolineBoyer
Copy link

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: 16.0
  • module version: 12.0.4
  • environment (e.g. node, browser, native): browser (and node)
  • used with (e.g. hapi application, another framework, standalone, ...): hapi application
  • any other relevant information:

How can we help?

Some users in production are being unsubscribe from the socket without us really knowing why. Their internet access is supposedly stable...
I feel I am missing some cases of automatic unsubscribe so I must ask : what are the different cases where the socket might trigger the onUnsubscribe function ?

Here are the different declarations:

/**CLIENT CODE connection **/
return this.socketClient.connect({
	reconnect: true, 	//whether the client should try to reconnect
	delay: 2000,		//time in milliseconds to wait between each reconnection attempt, cumulative
	maxDelay: 15000,	//the maximum delay time in milliseconds between reconnections
	retries: 10		//number of reconnection attempts
})
/** SERVER REGISTER **/
await server.register(
  {
    plugin: Nes,
    options: {
      heartbeat: {
        interval: 15000,
        timeout: 5000
      },
      auth: false
    }
  },
  {
    routes: process.env.ROOT_PATH ? {
      prefix: ROOT_PATH
    } : {}
  }
);


this.serverFromRequest.subscription(this.subscribingPath , {
          onSubscribe: (socket, path, params)=>{
            /** SOME CODE that has nothing to do with network **/
            //Managing page reloading by clearing a timeout
            if (this.onUnsubscribeTimeout) {clearTimeout(this.onUnsubscribeTimeout)}
          },
          onUnsubscribe: (socket, path, params)=>{
           /** SOME CODE that has nothing to do with network **/
                const unloadTimeout =  15000;
                this.onUnsubscribeTimeout = setTimeout(()=>{
                  
                 /** SOME CODE saying what should happen when socket is closed ( basically send message to client saying Chat is closed)
                }, unloadTimeout)
          }
        })

What do you think ?
Is the fact maxDelay very closed to unloadTimeout could explain the issue ?
Are my connect options not precise enough or too low ? Or the heartbeat maybe ?

What would be good production values according to your knowledge ?
Regards and thank you for nes !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant