Re: [xSocket-develop] Question: SSL with non-threaded onData() hangs sometimes
Status: Inactive
Brought to you by:
grro
|
From: Christian K. <ck...@vx...> - 2008-05-26 11:33:34
|
Hi Gregor,
thanks for your fast reply.
I already tried to send an amendment to my last mail (was rejected by list
server):
Sorry, forgot to mention a few important things:
- Connections are in ASYNC mode as tutorial explains
- both nodes can and probably will send data asynchronously at the same time
(no "synchronous" protocol behaviour as seen i.e. in HTTP)
- SSL Layer is the standard JSSE implementation, either 1.5.x or 1.6.x made
no
difference so far
The multi-threaded test-case is on its way. At the moment we're waiting for
the
next hang in non-threaded mode (hope to see something different in the
logs).
Hmm, you say SSL should work in non threaded mode - could it be an issue
(may be
with JVMs SSLEngine) if both nodes are sending a stream of data at the same
time?
I understand that you need a Junit test-case, therefore I would examine the
be-
haviour with two pseudo-clients sending random data to each other
continously.
Best regards,
Christian
________________________________
Von: Gregor Roth [mailto:gre...@go...]
Gesendet: Montag, 26. Mai 2008 13:19
An: xSo...@li...
Cc: Christian Kahlo
Betreff: Re: [xSocket-develop] Question: SSL with non-threaded
onData() hangs sometimes
Hi Christian,
have you already tested your code in the multithreaded mode?
If you call the connection methods only within a call back method
(thread) such as onData() or onConnect(), you will not have to synchronize
method calls on the Connection class. xSocket performs the call back methods
always in a serialized for a given connection.
Independent of this, SSL should work in a non threaded mode as well
as in a multi threaded mode. It is recommended to set the FlushMode to ASYCN
to avoid deadlocks. Did you done this?
If this doesn't help, you should file a bug. Please add also a JUnit
test based on your code.
Gregor
2008/5/26 Christian Kahlo <ck...@vx...>:
Hi there,
at first thanks for the good work. I stumbled over xSocket
and
instantly loved it. ;)
So, I was starting to write a repeater service using SSL.
That means a client and a server both connect the repeater
and
identify themselves either as being client or server and to
whom
they belong. The result is a pair of two connections -
similar to
the proxy example. (it's all about remote desktop stuff)
Everything is working fine - until some sporadic hang occurs
in the
onData handler. Because it is non-threaded the whole server
hangs.
The code:
public boolean onData(INonBlockingConnection c)
throws IOException, BufferUnderflowException,
MaxReadSizeExceededException {
Node n = (Node)c.getAttachment();
if(n != null && n.sessionID != null) {
Node n2 = n.server ?
viewers.get(n.sessionID) :
servers.get(n.sessionID);
if(n2 != null) {
System.out.print((n2.server ?
"S" : "C") +
c.available() + ">");
// before hang #1
ByteBuffer[] data =
c.readByteBufferByLength(c.available());
System.out.print("<" +
(n2.server ? "S" :
"C"));
// before hang #2
n2.c.write(data);
System.out.println("#");
}
}
return true;
}
I identified two positions where the code may hang. The
write hangs far more
often than the
read. But as I said - sometimes it's running for hours, even
days. In
another case it died
within 3 minutes. :(
Could anyone please give me a hint what to watch out for?
What to tune?
I supposed some synchronisation cludge with the SSL stack
and modified
xSocket, so that I
can deliver my own customized SSLEngine. I forced the
connection to use RC4
stream-cipher,
because I thought there may be some length difference issue
due to
padding/unpadding when
using a block-cipher - but nothing changed. :-/
Or do I simply _have to_ use multi-threading as soon as I
want to have SSL?
Did I understand the other threads correctly, that I would
have to
synchronize on the
connection objects for each read and write operation when
using
multi-threading?
Thanks in advance.
Best regards,
Christian
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
xSocket-develop mailing list
xSo...@li...
https://lists.sourceforge.net/lists/listinfo/xsocket-develop
|