Hello, thanks for your advice!
Actually, I was using ProtocolChain, but now I've added one more filter,
according to your advice which really makes sense. But the problem with
sending data to client persists.
That is how my server is started:
//...
//here i have my ssl parameters initialized
SSLConfig.DEFAULT_CONFIG = _sslConfig;
_controller = new Controller();
_connectorHandler =
(SSLConnectorHandler)_controller.acquireConnectorHandler(Controller.Protocol.TLS);
_connectorHandler = new SSLConnectorHandler(_sslConfig);
_engine = _sslConfig.createSSLContext().createSSLEngine();
_engine.setUseClientMode(false);
_connectorHandler.setSSLEngine(_engine);
_connectorHandler.setController(_controller);
_selectorHandler = new SSLSelectorHandler(false);
final SSLReadFilter readFilter = new SSLReadFilter();
readFilter.setSSLContext(_sslConfig.createSSLContext());
_selectorHandler.setPort(PORT);
_controller.setSelectorHandler(_selectorHandler);
_controller.setProtocolChainInstanceHandler(new
DefaultProtocolChainInstanceHandler()
{
@Override
public ProtocolChain poll()
{
ProtocolChain _protocolChain = protocolChains.poll();
if (_protocolChain == null)
{
_protocolChain = new DefaultProtocolChain();
_protocolChain.addFilter(readFilter);
_protocolChain.addFilter(new ClientRegFilter());
_protocolChain.addFilter(new DispatchFilter());
}
return _protocolChain;
}
}
);
ControllerUtils.startController(_controller);
_pipeline = new DefaultPipeline();
_pipeline.setMinThreads(20);
_pipeline.setMaxThreads(30);
_pipeline.initPipeline();
_pipeline.startPipeline();
In ClientRegFilter I add client to the map (key ~ SelectionKey, value ~
object, containing list of messages for the given client)
In DispatchFilter I parse the message from WorkerThread's ByteBuffer, and as
the answer
I want to send some data back to client, by passing a callable object from
the map to the pipeline. The Call method of this object sends one or more
messages to the given client.
But instead of sending i'm still getting that NullPointerException.
But if I try to execute Call() method directly (i.e. not putting it into
pipeline), i get
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at
com.sun.net.ssl.internal.ssl.EngineInputRecord.bytesInCompletePacket(EngineInputRecord.java:152)
at
com.sun.net.ssl.internal.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:754)
at
com.sun.net.ssl.internal.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:669)
etc.....
on the client side. Exactly the same error message i get if i replace my
DispatchFilter with SSLEchoFilter in ProtocolChain (after the successful
handshake client starts communicating via messages).
Maybe the reason of the faulty behavior is in how my client gets messages?
Because I wanted to have there a similar structure to the server's one. I
mean, my client has its own ProtocolChain and CallbackHandler, which on Read
event does
public void onRead(IOEvent<Context> ioEvent)
{
try
{
Context ctx = ioEvent.attachment();
ctx.getProtocolChain().execute(ctx);
}
catch(Exception e)
{
e.printStackTrace();
}
}
And in the ProtocolChain i have SSLReadFilter and my own filter to parse the
message. It worked well for me in TCP case, maybe with SSL such scheme is
too bad?
So, I'm still stuck with sending messages.
I really appreciate your advices.
Thanks,
-- Quende
--
View this message in context: http://www.nabble.com/Problem-with-SSL-tp19709902p19742991.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.