Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333109

Summary: Websocket connections sometimes closed spontaneously when using SslSelectChannelConnector
Product: [RT] Jetty Reporter: Jeremy Stone <jeremy.stone>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jeremy.stone, jetty-inbox, mgorovoy
Version: 7.1.3   
Target Milestone: 7.1.x   
Hardware: All   
OS: All   
Whiteboard:

Description Jeremy Stone CLA 2010-12-22 12:04:09 EST
Build Identifier: 7.1.6.v20100715

Using SslSelectChannelConnector a web socket connection is sometimes closed apparently spontaneously. 

Debugging it, what seems to occur is that the WebSocketConnection handle() method is closing the endpoint when _generator.flush() returns -1. (This happens because SslSelectChannelEndpoint.flush() returns -1 when its buffer and header are empty.)

Now the WebSocketGenerator.flush() method returns and nulls out its _buffer field when the buffer is empty, but the blocking flush(long blockFor) (which uses expelBuffer()) does not. Is this an oversight or is it deliberate? I.e. should the buffer be returned and nulled on all public flush(...) method calls that leave it empty?

On a subsequent call to flush(), the private WebSocketGenerator.flushBuffer() method returns zero for a null buffer but -1 (from SslSelectChannelEndpoint.flush()) for an empty non-null buffer. (Note that the buffer will be returned and nulled on this subsequent call).

I suspect this may be causing the websocket closes that I am seeing.

I have not seen this issue when using SslSocketConnector.

[Sorry I tried to send this to netty-users@eclipse.org - but it was bounced.]


Reproducible: Sometimes

Steps to Reproduce:
Can probably rig up some test case for this if required.
Comment 1 Greg Wilkins CLA 2011-09-06 01:12:05 EDT
While we have not addressed this issue in particular, we have significantly refactored websocket and fixed many similar issues since it was raised - specifically with closing, timeouts etc.

The current 7.5.x implementation is moderately well tested, so please try that and reopen if you see it again.