How handle socket io reconnect issue from server side? - socket.io

Socket disconnect and reconnect with new socket id.
How to handle it from server side.
Is there possibility server configuration not match with socket.io
Socket disconnect and reconnect with new socket id.
How to handle it from server side.
Is there possibility server configuration not match with socket.

Related

How long can a RSocket connection last?

I understand that RSocket connection is bidirectional.
How long can a client be connected to a server via RSocket before the connection is terminated?
And if the connection actually does terminate, how does it get reconnected if the server wants to send something to the client?
Minutes, Days or Weeks?
It's dependent on your use. Server to Server with lifetime of those servers. Or Mobile connecting to a backend with sticky routing and resumption.
However while the connection is bi-directional, the client must always initiate the (re-)connection.
https://github.com/rsocket/rsocket-java/blob/d903e9635a159285b6943ea93156c31aa406ba5d/rsocket-examples/src/main/java/io/rsocket/examples/transport/tcp/resume/ResumeFileTransfer.java

ListenSocket ClientSocket Go

In this article about Go Web Server, there're Listen Socket and Client Socket in Go,
I can't understand why GoLang need two sockets Listen Socket, Client Socket but not just one socket, can anyone explain its concept or give a metaphor?
EDIT : I update my answer.
Maybe I misunderstanding the graph or the graph isn't draw very well, possibly Listen Socket, Client Socket are same socket, if the socket hasn't accept connection from client, it's called Listen Socket, and after it accept the connection, it's renamed to Client Socket, there's only one socket with different stage and name.
UPDATE 1:
I find a better article and graph about Socket Working Here.
In the grpah of article, it's clear when there's new connection, TCP Server will
create a new socket to handle the connection, and the Listen Socket continuing listening for other connections.
Here's a paragraph in the article:
The first socket created by a TCP server, via NetSock_Open(), is typically designated a listen socket , and, after the call to NetSock_Listen(), remains open indefinitely, to allow the server to respond to various connection requests. Rather than using this socket to exchange data with requesting clients, the server will create a new socket for each request.
UPDATE 2
Since first update is working on Micrium, I find another seems more general TCP working instuction Here:
TCP connection flow The following sequence shows the flow of a TCP
connection:
The server creates the listener socket that is waiting for remote clients to connect.
The client issues the connect() socket function to start the TCP handshake (SYN, SYN/ACK, ACK). The server issues the accept() socket
function to accept the connection request.
The client and server issue the read() and write() socket functions to exchange data over the socket.
Note: There are several SSL APIs that you can use to send and receive data other than the read() and write() socket functions.
Either the server or the client decides to close the socket. This causes the TCP closure sequence (FINs and ACKs) to occur.
The server either closes the listener socket or repeats beginning with step 2 to accept another connection from a remote client.
Note: Normally after the accept() socket function ends, the server divides
into two processes (or threads). The first process handles the
connection with the client and the second process issues the next
accept() socket function. Figure 1 shows an example of a TCP
connection:
Note:
I find another Socker Programming Tutorial mention about working detail in TCP.
And In .NET Framework MSDN, the explanation about Socket.Accept Method() says Accept synchronously extracts the first pending connection request from the connection request queue of the listening socket, and then creates and returns a new Socket.
I have skimmed RFC about TCP before Update 1, but I didn't see it mention the detail that Listen use one socket, and when Accept it'll create another new Socket.
Maybe the thorough way is to research the Source Code about Create Socket and Connection in Go, but I'm not consiedring to do it now.

socket.io - Client socket time out

Socket.io has connection and disconnect events.
Does socket.io has timeout event for client sockets, that are already connected?
https://github.com/socketio/socket.io

Can websocket server disconnect a client?

I'm using node.js with the socket.io module. I have a need to disconnect a websocket client on occasion. Can I do this forcibly from the server, or does the server have to "ask" the client to disconnect?
Note. From the server I've tried socket.end() which works from the client, but not on the server side.

How reconnect from server to client

I'am able to detect when client disconnect from a server by this code:
self._session.socket.on("close", function() {
console.log("client disconnected");
}
But how can I try reconnect to the disconnected client?
You cannot connect from server to client as client isn't listening to the websocket, but just connecting (to the server).
However, you can put a code in your client to reconnect it at onclose (or just close) event. Generally this occurs by recreating the WebSocket object in the client with the correct parameters.
Something as:
function connect(){
var mywebsocket = new WebSocket("ws://(your url)");
// ... my callbacks and functions...
mywebsocket.onclose = connect; // or arguments.callee
}
connect();
Should work correctly. ;)
Good luck.
If the client got disconnected for some reason (internet connection disruption/server issues) it will automatically reconnect on its own. To see how many attempts have been made or the status have a look at http://docs.meteor.com/#meteor_status
Since version 0.6.3 if the internet was disconnected. As soon as the internet is back it will attempt to reconnect too.
To reconnect from your code somewhere you can run Meteor.reconnect() from the client.
Unfortunately the meteor client can't listen for connections from the server so the server can't initiate a reconnection, you need some kind of connection to a server to send a message to the client to do something such as a reconnection.

Resources