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
Related
We are using tomcat websocket implementation in our web application. Messages are pushed from server to client through websockets. Web socket messages are not pushed when intermittant connection drop or network is switch over but still web application is connected.
Let say for example i am connected to LAN and logged in app, now i connecting through wifi after wifi successfully connected i am disconnecting LAN with in fraction of second network is switched from LAN to wifi But after this messages are not pushed from server to client through websockets.
After network switch if i check the state of the websocket(readyState) which says 1 which means websocket connection is open but actually its not.
Can anyone faced this issue earlier and provide your suggestions.
Thanks
You must create a connection drop detection mechanism. The WebSocket protocol has ping/pong frames, but I don't know if Tomcat has that functionality. In some Webscoket frameworks you can define a timeout interval, and the server will ping the client regularly, if the client miss some pongs is disconnected.
If that functionality is not provided by Tomcat, you can still create your own. Just define a special type of message and repeat it to the server from the client. If you do not get any of those messages for a while, disconnect.
One of my app need socket connection.
I tested on nitrous.io, but their free account always close the socket connection if there is no signal between server and client more than 1 minute.
Just wonder if there is similar socket connection limitation on heroku?
Your comment welcome
Heroku has support for WebSockets, with the usual 30s timeout limitation. This can be easily worked-around by sending heartbeat packets.
https://devcenter.heroku.com/articles/heroku-labs-websockets
Case:
A WebSocket connection have been established between the client and server endpoint.
Now I have the network connection go down (for example the ADSL dies), after 10 min I recover the network, I find that the client and server are still able to communicate with each
other. Why?
Note:
The client was developed with Java-WebSocket framework, and the client did with ws4py.
1 - If they did not try to exchange any data and only the connection (not the endpoints) between them is down, this is normal behaviour.
2 - If the websocket connection ended, Browser may have re-established it without you knowing about it. I just checked that this is not normal behaviour. But maybe there is some parameter somewhere :-)
If I am not wrong, to have a push technology the client ( say browser ) also needs to run a small web server which is listening on some port ( say ijetty runs on 8080 ). Now when the actual server comes to know about any event, it sends the event to client. This way there is no PULL mechanism involved at all. Is this right ? OR there is a persistent connection involved and server sends the data on that connection whenever the event happens. My question is : in the former case ( if it is true ), how does server know about client's IP ?
WebSockets working with socket based on TCP connection, basically the client make a request for connection to the server with a challenge, websocket version, ip and more data, then the server decrypts the challenge and return his result back to the client, this process called Handshake.
If the handshake is approved, the connection is made, the socket connection remains open between the client and the server, heartbeats will be sent from the server to the client like a ping to check if the connection is still open.
read this wiki to find out more:
http://en.wikipedia.org/wiki/WebSocket
Without timeout? Or is there even a timeout?
There is no limit on the lifetime of a connected jid. For command line bots, it is a good practice to send periodic ping packets to the server, just to make sure opened socket doesn't drop after some period of inactivity.
In case your client is connected from browser and suppose the user refreshes the browser without disconnecting from the jabber server. User can still use saved (via cookie/session) jid,sid,rid combination to reconnect with previously opened session. However, bosh connection manager will drop the connection after "X" seconds of inactivity.
XMPP does not say anything about having or not a timeout. So, in theory, you XMPP Session could last as long as the TCP connection is established.
You are free to implement a timeout in your client or server though...