V
V
vetsmen2017-11-21 02:19:48
JavaScript
vetsmen, 2017-11-21 02:19:48

Forwarding a token through sockets, is this approach adequate?

Good day. There is a connection:

const SocketInstance = socketio('http://5.25.22.14:1923', {
  query:'token=' + token
});

In this instance, I initialize the user token for authorization. The problem is that in order to change it, I constantly have to reconnect the socket:
SocketInstance.io.disconnect();
   SocketInstance.io.opts.query = {
   token: 'newtoken'
   }
   SocketInstance.io.connect();

Is this approach appropriate at all? It turns out that when authorizing / logging out of the account, the user will constantly reconnect to the sockets.
If not, are there alternatives?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2017-11-21
@VELIK505

Yes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question