top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Connection not closed at TCP level with websocket application

0 votes
120 views

We have a websocket application which keeps writing data to the clients.

We found that when tabs (not whole browser) of Firefox (ver. 22) is closed, the websocket connection is not closed. Anyway, reproducibility is very low. And the sendQ (netstat -an) keeps growing

So, what we did is. we kept sending heart beat from client. If this heart beat timeout occurs, we are trying to close the connection as follows

ByteBuffer bbuff = ByteBuffer.allocate(1);
bbuff.put((byte) 0);
messageInbound.getWsOutbound().close(0, bbuff);

Is this correct approach to close the connection from server? Because, the connection is not closed at lower level (netstat -an). Anyway, writing data to it , is stopped and sendQ stops growing.

# netstat -an | grep :8080
tcp 0 402376 172.22.59.176:8080 198.162.18.207:64805 ESTABLISHED
posted Aug 7, 2013 by Deepankar Dubey

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
A ping from the server followed by a close if no pong is received within a set timeout should be fine.

1 Answer

+1 vote

You can try to close the connection from the client with something like:
document.addEventListener('beforeunload', function() {ws.close();})

answer Aug 7, 2013 by Mandeep Sehgal
Similar Questions
+1 vote

We have had issues with system resources, primarily RAM, maxing out and effectively overwhelming an Apache web server.
We have noticed that some of the default TCP time settings on Solaris 10 seem really high. Is there any sort of standard TCP settings that have been adopted, or suggested, for a Solaris 10 system running Apache 2.2?Can anyone share what they have done?

+2 votes

What reasoning could be behind not using the TCP/SCTP for GTPv2 protocol ?

+1 vote

As per tomcat's performance tuning doc, 'tcpNoDelay' can be enabled/disabled at connector level.

Is there a programmatic way to set 'tcpNoDelay' to true for web socket connections ? I am using tomcat's proprietary web socket APIs in my application.

I have gone though the API documentation of tomcat's proprietary web socket implementation, I didn't see any API which allows application to override the 'tcpNoDelay' value.

As per doc for "writeTextMessage(CharBuffer msgCb)" of 'WsOutbound', for each write, tomcat flushes the socket buffer and sends the new frame with the buffer passed. Does that mean, flushing of socket buffer gives the same effect of disabling naggle's algorithm ?

+4 votes

Out of three prominent advance transport protocols (TCP, UDP and SCTP) which is the best to use and why should i use that protocol ?

+2 votes

Is there a standard way to access ServletContext from a WebSocket ServerEndpoint ?


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...