Re: [xSocket-develop] Question: SSL with non-threaded onData() hangs sometimes
Status: Inactive
Brought to you by:
grro
|
From: Gregor R. <gre...@go...> - 2008-05-26 11:18:53
|
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
>
|