xsocket-develop Mailing List for xsocket
Status: Inactive
Brought to you by:
grro
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(12) |
Oct
(9) |
Nov
(11) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(8) |
Feb
(9) |
Mar
(9) |
Apr
(22) |
May
(28) |
Jun
(17) |
Jul
(10) |
Aug
(19) |
Sep
(4) |
Oct
(14) |
Nov
(26) |
Dec
(25) |
| 2009 |
Jan
(13) |
Feb
(17) |
Mar
(12) |
Apr
(4) |
May
(16) |
Jun
(6) |
Jul
(10) |
Aug
(24) |
Sep
(6) |
Oct
(5) |
Nov
(13) |
Dec
(10) |
| 2010 |
Jan
(17) |
Feb
(21) |
Mar
(10) |
Apr
(8) |
May
(2) |
Jun
(14) |
Jul
(7) |
Aug
(10) |
Sep
(7) |
Oct
(3) |
Nov
|
Dec
(2) |
| 2011 |
Jan
(1) |
Feb
(5) |
Mar
(1) |
Apr
|
May
(5) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(3) |
Nov
|
Dec
|
| 2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
(3) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
|
From: Fu, X. <xia...@ws...> - 2020-12-26 06:41:54
|
Dear developers:
I have opened a xSocket bug at https://sourceforge.net/p/xsocket/bugs/25/:
During xSocket integration testing, I developed one sample application, based on NonBlockingConnection, whose client send a text message, followed by another client sending another, to the server.
The source: org.xsocket.connection.IoConnector:
private void handleConnect() {
Set<selectionkey> selectedEventKeys = selector.selectedKeys();
Iterator<selectionkey> it = selectedEventKeys.iterator();
while (it.hasNext()) {
SelectionKey eventKey = it.next();
it.remove();
RegisterTask registerTask = (RegisterTask) eventKey.attachment();
......
}
}</selectionkey></selectionkey>
The sink: org.xsocket.connection:
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name) {
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " + ioe.toString();
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
The statement "LOG.severe(text)" doesn't have LOG severe control.
The Tainted path:
org.xsocket.connection.IoConnector -->
org.xsocket.connection.IoConnector$RegisterTask -->
org.xsocket.connection.IoConnector -->
org.xsocket.connection.ConnectionManager -->
org.xsocket.connection.NonBlockingConnection$SyncIoConnectorCallback -->
org.xsocket.connection.ConnectionManager -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.NonBlockingConnection$SyncIoConnectorCallback -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.ConnectionManager -->
org.xsocket.connection.ConnectionManager$TimeoutMgmHandle -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.IoConnector$RegisterTask -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.ConnectionManager$TimeoutMgmHandle -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.IoSocketDispatcherPool
Could you confirm it?
Thank you very much!
Yours sincerely,
Xiaoqin Fu
|
|
From: Fu, X. <xia...@ws...> - 2019-08-17 06:33:44
|
Dear developers:
I am a Ph.D. student at Washington State University. I applied dynamic taint analyzer (distTaint) to xSocket (version 2.8.5). And then I find a security vulnerability from a tainted path.
During xSocket integration testing, I developed one sample application, based on NonBlockingConnection, whose client send a text message, followed by another client sending another, to the server.
The source: org.xsocket.connection.IoConnector:
private void handleConnect() {
Set<SelectionKey> selectedEventKeys = selector.selectedKeys();
Iterator<SelectionKey> it = selectedEventKeys.iterator();
while (it.hasNext()) {
SelectionKey eventKey = it.next();
it.remove();
RegisterTask registerTask = (RegisterTask) eventKey.attachment();
......
}
}
The sink: org.xsocket.connection:
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name) {
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " + ioe.toString();
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
The statement "LOG.severe(text)" doesn't have LOG severe control.
The Tainted path:
org.xsocket.connection.IoConnector -->
org.xsocket.connection.IoConnector$RegisterTask -->
org.xsocket.connection.IoConnector -->
org.xsocket.connection.ConnectionManager -->
org.xsocket.connection.NonBlockingConnection$SyncIoConnectorCallback -->
org.xsocket.connection.ConnectionManager -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.NonBlockingConnection$SyncIoConnectorCallback -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.ConnectionManager -->
org.xsocket.connection.ConnectionManager$TimeoutMgmHandle -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.IoConnector$RegisterTask -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.ConnectionManager$TimeoutMgmHandle -->
org.xsocket.connection.NonBlockingConnection -->
org.xsocket.connection.IoSocketDispatcherPool
I am going to submit a CVE, so please confirm this is not a true positive.
It was recorded at https://sourceforge.net/p/xsocket/bugs/25/
Please help me confirm it.
Thank you very much!
Yours sincerely
Xiaoqin Fu
|
|
From: Fu, X. <xia...@ws...> - 2019-08-15 16:53:48
|
Dear developers:
I am a Ph.D. student at Washington State University. I applied dynamic taint analyzer (distTaint) to xSocket (version 2.8.5). And then I find a security vulnerability from tainted paths:
In org.xsocket.connection.IoSocketDispatcher,
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name) {
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " + ioe.toString();
LOG.isLoggable(Level.SEVERE)
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
Sensitive information about the selector may be leaked. The LOG.isLoggable(Level.SEVERE) conditional statement should be added
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name) {
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " + ioe.toString();
if (LOG.isLoggable(Level.SEVERE))
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
It was recorded at https://sourceforge.net/p/xsocket/bugs/24/
Please help me confirm it.
Thank you very much!
Yours sincerely
Xiaoqin Fu
|
|
From: Xiaoqin Fu <xia...@gm...> - 2019-08-14 18:26:31
|
Dear developers:
Dear developers:
I am a Ph.D. student at Washington State University. I applied dynamic
taint analyzer (distTaint) to xSocket (version 2.8.5). And then I find a
security vulnerability from tainted paths:
In org.xsocket.connection.IoSocketDispatcher,
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name)
{
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " +
ioe.toString();
LOG.isLoggable(Level.SEVERE)
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
Sensitive information about the selector may be leaked. The
LOG.isLoggable(Level.SEVERE) conditional statement should be added
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name)
{
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " +
ioe.toString();
if (LOG.isLoggable(Level.SEVERE))
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
Please help me confirm it.
Thank you very much!
Yours sincerely
Xiaoqin Fu
|
|
From: Xiaoqin Fu <xia...@gm...> - 2019-08-13 04:52:13
|
Dear developers:
I am a Ph.D. student at Washington State University. I applied dynamic
taint analyzer (distTaint) to xSocket (version 2.8.5). And then I find a
security vulnerability from tainted paths:
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String
name) {
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " +
ioe.toString();
LOG.isLoggable(Level.SEVERE)
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
Sensitive information about the selector may be leaked. The
LOG.isLoggable(Level.SEVERE) conditional statement should be added
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name)
{
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " +
ioe.toString();
if (LOG.isLoggable(Level.SEVERE))
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
It was recorded at https://sourceforge.net/p/xsocket/bugs/24/.
Please help me confirm it.
Thank you very much!
Yours sincerely
On Sat, Aug 3, 2019 at 11:44 AM Xiaoqin Fu <xia...@gm...> wrote:
> Dear developers:
> I am a Ph.D. student at Washington State University. I applied dynamic
> taint analyzer (distTaint) to xSocket (version 2.8.5). And then I find a
> security vulnerability from tainted paths:
> public IoSocketDispatcher(AbstractMemoryManager memoryManager, String
> name) {
> ......
> try {
> selector = Selector.open();
> } catch (IOException ioe) {
> String text = "exception occured while opening selector. Reason: " +
> ioe.toString();
> LOG.isLoggable(Level.SEVERE)
> LOG.severe(text);
> throw new RuntimeException(text, ioe);
> }
> ......
> }
> Sensitive information about the selector may be leaked. The
> LOG.isLoggable(Level.SEVERE) conditional statement should be added
> public IoSocketDispatcher(AbstractMemoryManager memoryManager, String
> name) {
> ......
> try {
> selector = Selector.open();
> } catch (IOException ioe) {
> String text = "exception occured while opening selector. Reason: " +
> ioe.toString();
> if (LOG.isLoggable(Level.SEVERE))
> LOG.severe(text);
> throw new RuntimeException(text, ioe);
> }
> ......
> }
>
> Please help me confirm it.
>
> Thank you very much!
> Yours sincerely
> Xiaoqin Fu
>
>
|
|
From: Fu, X. <xia...@ws...> - 2019-08-09 00:30:48
|
Dear developers:
I am a Ph.D. student at Washington State University. I applied dynamic taint analyzer (distTaint) to xSocket (version 2.8.5). And then I find a security vulnerability from tainted paths:
In org.xsocket.connection.IoSocketDispatcher,
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name) {
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " + ioe.toString();
LOG.isLoggable(Level.SEVERE)
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
Sensitive information about the selector may be leaked. The LOG.isLoggable(Level.SEVERE) conditional statement should be added
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name) {
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " + ioe.toString();
if (LOG.isLoggable(Level.SEVERE))
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
Please help me confirm it and give it a CVE ID.
Thank you very much!
Yours sincerely
Xiaoqin Fu
|
|
From: Xiaoqin Fu <xia...@gm...> - 2019-08-03 18:44:56
|
Dear developers:
I am a Ph.D. student at Washington State University. I applied dynamic
taint analyzer (distTaint) to xSocket (version 2.8.5). And then I find a
security vulnerability from tainted paths:
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String
name) {
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " +
ioe.toString();
LOG.isLoggable(Level.SEVERE)
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
Sensitive information about the selector may be leaked. The
LOG.isLoggable(Level.SEVERE) conditional statement should be added
public IoSocketDispatcher(AbstractMemoryManager memoryManager, String name)
{
......
try {
selector = Selector.open();
} catch (IOException ioe) {
String text = "exception occured while opening selector. Reason: " +
ioe.toString();
if (LOG.isLoggable(Level.SEVERE))
LOG.severe(text);
throw new RuntimeException(text, ioe);
}
......
}
Please help me confirm it.
Thank you very much!
Yours sincerely
Xiaoqin Fu
|
|
From: Grzegorz B. <grz...@co...> - 2015-03-24 15:14:19
|
Hello,
I discovered a bug in xSocket 2.8.15 which prevents JVM from releasing
underlying file descriptors.
The bug is triggered by calling one of the following two methods:
org.xsocket.connection.AbstractNonBlockingStream.transferFrom(FileChannel)
org.xsocket.connection.NonBlockingConnectionPool.NonBlockingConnectionProxy.transferFrom(FileChannel)
They depend on the flawed implementation of MappedByteBuffer which is
known to keep file handles despite closing the corresponding FileChannel.
As a result, deleting or moving such a file on Windows OS is not
possible, because the MappedByteBuffer remains valid until it's garbage
collected. Linux is not affected, because it allows to modify opened
files. This bug is reproducible on JDK 1.7 and 1.8, I haven't tested it
on the older ones.
I've prepared a fix that seems to work, below is the diff output. I hope
it will be released in the upcoming version.
Index: src/org/xsocket/connection/AbstractNonBlockingStream.java
===================================================================
@@ -31,13 +31,11 @@
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
-import java.nio.MappedByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
-import java.nio.channels.FileChannel.MapMode;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -1237,7 +1235,6 @@
final long size = fileChannel.size();
long remaining = size;
- long offset = 0;
long length = 0;
do {
@@ -1247,10 +1244,12 @@
length = remaining;
}
- MappedByteBuffer buffer =
fileChannel.map(MapMode.READ_ONLY, offset, length);
+ ByteBuffer buffer = ByteBuffer.allocate((int) length);
+ fileChannel.read(buffer);
+ buffer.flip();
long written = write(buffer);
+ buffer.clear();
- offset += written;
remaining -= written;
} while (remaining > 0);
Index: src/org/xsocket/connection/NonBlockingConnectionPool.java
===================================================================
@@ -30,12 +30,10 @@
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
-import java.nio.MappedByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
-import java.nio.channels.FileChannel.MapMode;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
@@ -2961,7 +2959,6 @@
final long size = fileChannel.size();
long remaining = size;
- long offset = 0;
long length = 0;
do {
@@ -2971,10 +2968,11 @@
length = remaining;
}
- MappedByteBuffer buffer =
fileChannel.map(MapMode.READ_ONLY, offset, length);
+ ByteBuffer buffer =
ByteBuffer.allocate((int) length);
+ fileChannel.read(buffer);
long written = write(buffer);
+ buffer.clear();
- offset += written;
remaining -= written;
} while (remaining > 0);
--
Regards,
Grzegorz Byczyński
|
|
From: nova s. <mar...@gm...> - 2014-10-08 08:29:16
|
Hi Cristina,
>From the source I've traced. if we set ConnectionTimeout parameter to 0,
then it will use the default IConnection.MAX_TIMEOUT_MILLIS which is
Long.MAX_VALUE.
So if you want to never stop the connections, I suggest to reassign the
connection timeout each time the onConnectionTimeout method is reached.
Regards,
Nova.S
On Mon, Oct 6, 2014 at 9:34 PM, MANITIU, Cristina Maria (Cristina Maria)**
CTR ** <cri...@al...> wrote:
> Hello,
>
>
>
> I understand from your answer that If we don’t use “nbc.close()” the
> connection will never be closed. But if we set ConnectionTimeout parameter
> to 0, isn’t the same thing (the connection will never be stopped)?
>
> The whole idea is to never stop the connections, that is what we are
> trying.
>
>
>
> Thank you,
>
> Cristina
>
> *From:* nova saputra [mailto:mar...@gm...]
> *Sent:* Monday, October 06, 2014 11:58 AM
> *To:* MANITIU, Cristina Maria (Cristina Maria)** CTR **
> *Cc:* xso...@li...
> *Subject:* Re: [xSocket-develop] Question: ConnectionTimeout
>
>
>
> Hi Cristina,
>
>
>
> IMHO if you want to keep the connection, you dont need to do
> "nbc.close();".
>
> It will close connection even you return true on the method.
>
> Have you tried using IIdleTimeoutHandler? I think thats what you are
> looking :)
>
>
>
>
>
> Regards,
>
> Nova.S
>
>
>
>
>
> On Thu, Sep 4, 2014 at 9:46 PM, MANITIU, Cristina Maria (Cristina Maria)**
> CTR ** <cri...@al...> wrote:
>
> Hello,
>
>
>
> I have a question regarding ConnectionTimeout parameter
> and onConnectionTimeout method: if we set the value for ConnectionTimeout
> to 0 it means that the connection will never timeout and the method
> onConnectionTimeout will never be called?
>
> Or there is another method to never close INonBlockingConnection?
>
> In our code we have implemented the method onConnectionTimeout as
> you specify in your documentation:
>
>
>
> *public* *boolean* onConnectionTimeout(INonBlockingConnection nbc)
> *throws* *IOException* {
>
>
>
> nbc.close();
>
> *return* *true*;
>
> }
>
>
>
> And we don’t want to close at a specified amount of time the
> NonBlockingConnections.
>
>
>
> Any suggestions will be appreciated.
>
>
>
> Thank you,
>
> Cristina Manitiu
>
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds. Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> xSocket-develop mailing list
> xSo...@li...
> https://lists.sourceforge.net/lists/listinfo/xsocket-develop
>
>
>
|
|
From: MANITIU, C. M. (C. Maria)** C. **
<cri...@al...> - 2014-10-06 14:34:37
|
Hello,
I understand from your answer that If we don’t use “nbc.close()” the connection will never be closed. But if we set ConnectionTimeout parameter to 0, isn’t the same thing (the connection will never be stopped)?
The whole idea is to never stop the connections, that is what we are trying.
Thank you,
Cristina
From: nova saputra [mailto:mar...@gm...]
Sent: Monday, October 06, 2014 11:58 AM
To: MANITIU, Cristina Maria (Cristina Maria)** CTR **
Cc: xso...@li...
Subject: Re: [xSocket-develop] Question: ConnectionTimeout
Hi Cristina,
IMHO if you want to keep the connection, you dont need to do "nbc.close();".
It will close connection even you return true on the method.
Have you tried using IIdleTimeoutHandler? I think thats what you are looking :)
Regards,
Nova.S
On Thu, Sep 4, 2014 at 9:46 PM, MANITIU, Cristina Maria (Cristina Maria)** CTR ** <cri...@al...<mailto:cri...@al...>> wrote:
Hello,
I have a question regarding ConnectionTimeout parameter and onConnectionTimeout method: if we set the value for ConnectionTimeout to 0 it means that the connection will never timeout and the method onConnectionTimeout will never be called?
Or there is another method to never close INonBlockingConnection?
In our code we have implemented the method onConnectionTimeout as you specify in your documentation:
public boolean onConnectionTimeout(INonBlockingConnection nbc) throws IOException {
nbc.close();
return true;
}
And we don’t want to close at a specified amount of time the NonBlockingConnections.
Any suggestions will be appreciated.
Thank you,
Cristina Manitiu
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
xSocket-develop mailing list
xSo...@li...<mailto:xSo...@li...>
https://lists.sourceforge.net/lists/listinfo/xsocket-develop
|
|
From: nova s. <mar...@gm...> - 2014-10-06 08:57:40
|
Hi Cristina,
IMHO if you want to keep the connection, you dont need to do "nbc.close();".
It will close connection even you return true on the method.
Have you tried using IIdleTimeoutHandler? I think thats what you are
looking :)
Regards,
Nova.S
On Thu, Sep 4, 2014 at 9:46 PM, MANITIU, Cristina Maria (Cristina Maria)**
CTR ** <cri...@al...> wrote:
> Hello,
>
>
>
> I have a question regarding ConnectionTimeout parameter
> and onConnectionTimeout method: if we set the value for ConnectionTimeout
> to 0 it means that the connection will never timeout and the method
> onConnectionTimeout will never be called?
>
> Or there is another method to never close INonBlockingConnection?
>
> In our code we have implemented the method onConnectionTimeout as
> you specify in your documentation:
>
>
>
> *public* *boolean* onConnectionTimeout(INonBlockingConnection nbc)
> *throws* *IOException* {
>
>
>
> nbc.close();
>
> *return* *true*;
>
> }
>
>
>
> And we don’t want to close at a specified amount of time the
> NonBlockingConnections.
>
>
>
> Any suggestions will be appreciated.
>
>
>
> Thank you,
>
> Cristina Manitiu
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds. Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> xSocket-develop mailing list
> xSo...@li...
> https://lists.sourceforge.net/lists/listinfo/xsocket-develop
>
>
|
|
From: MANITIU, C. M. (C. Maria)** C. **
<cri...@al...> - 2014-09-04 17:13:34
|
Hello,
I have a question regarding ConnectionTimeout parameter and onConnectionTimeout method: if we set the value for ConnectionTimeout to 0 it means that the connection will never timeout and the method onConnectionTimeout will never be called?
Or there is another method to never close INonBlockingConnection?
In our code we have implemented the method onConnectionTimeout as you specify in your documentation:
public boolean onConnectionTimeout(INonBlockingConnection nbc) throws IOException {
nbc.close();
return true;
}
And we don't want to close at a specified amount of time the NonBlockingConnections.
Any suggestions will be appreciated.
Thank you,
Cristina Manitiu
|
|
From: 陳毅泰 <liq...@gm...> - 2011-07-16 04:38:46
|
Does any one have the same problem that use getBlockingConnection from the different threads, but get the same connection and cause the return message receive from the wrong thread?? I cant find the old version's issue list, so I am not sure will it be solve by upgrade the new xsocket version... Thanks a lot... |
|
From: HU,nan xa.V. <na...@xa...> - 2011-07-01 01:40:45
|
My client uses xsocket to communicate with the server which writen by c++ , the server delimit characters by 0x00 and 0xff(0x00: start , 0xff: end).
I can not find the methord which delimite by bytes on NonBlockingConnection , please give me some help ,thank you very much.
Email:na...@xa...
MSN: tia...@16...
|
|
From: deyan p. <dey...@gm...> - 2011-05-04 14:08:27
|
Hello there,
I experience some strange blocking problems using the write method of
the INonBlockingConnection class. It wait for long time. Here is a jstack:
"XSocket Worker Thread" prio=10 tid=0x00007f6d64087800 nid=0x5e76 in
Object.wait() [0x00007f6d6a70d000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e0cbc9d8> (a
org.xsocket.connection.NonBlockingConnection$SynchronWriter)
at
org.xsocket.connection.NonBlockingConnection$SynchronWriter.syncWrite(NonBlockingConnection.java:2374)
- locked <0x00000000e0cbc9d8> (a
org.xsocket.connection.NonBlockingConnection$SynchronWriter)
at
org.xsocket.connection.NonBlockingConnection.internalFlush(NonBlockingConnection.java:2211)
at
org.xsocket.connection.NonBlockingConnection.onWriteDataInserted(NonBlockingConnection.java:2045)
at
org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1060)
at
org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1039)
at
org.xsocket.connection.SynchronizedNonBlockingConnection.write(SynchronizedNonBlockingConnection.java:552)
- locked <0x00000000e0cbc748> (a
org.xsocket.connection.NonBlockingConnection)
at
com.egt.egm.server.roulette.xsocket_server.XSocketDataHandler.broadcastMessage(XSocketDataHandler.java:521)
at
com.egt.egm.server.roulette.xsocket_server.XSocketMessageWorker.run(XSocketMessageWorker.java:54)
at java.lang.Thread.run(Thread.java:662)
Can you help in anyway? Also I store all active connections in a map
which is accessed concurrently and I am using the suggested final
INonBlockingConnection nbc = ConnectionUtils
.synchronizedConnection(_nbc).
Thanks in advance.
|
|
From: seyhan u. <uca...@gm...> - 2011-05-04 08:43:47
|
Hi everybody;
I have an error that I sometimes met. The error stack trace is below;
2011-05-04-xWorkerPool-1-thread-2--FATAL-su.games.engine.communication.gameSocketDataHandler:ServiceSocketDataHandler.onData:
could not write. channel is close or not initialized
(id=25c1031512fb560155a71db6548S1517c (closed))-----
org.xsocket.connection.ExtendedClosedChannelException: could not
write. channel is close or not initialized
(id=25c1031512fb560155a71db6548S1517c (closed))
at org.xsocket.connection.AbstractNonBlockingStream.ensureStreamIsOpenAndWritable(AbstractNonBlockingStream.java:1537)
at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1054)
at org.xsocket.connection.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1039)
at su.games.engine.communication.ServiceSocketDataHandler.onData(ServiceSocketDataHandler.java:63)
at org.xsocket.connection.HandlerAdapter.performOnData(HandlerAdapter.java:242)
at org.xsocket.connection.HandlerAdapter.access$200(HandlerAdapter.java:42)
at org.xsocket.connection.HandlerAdapter$PerformOnDataTask.run(HandlerAdapter.java:210)
at org.xsocket.SerializedTaskQueue.performPendingTasks(SerializedTaskQueue.java:161)
at org.xsocket.SerializedTaskQueue.access$100(SerializedTaskQueue.java:40)
at org.xsocket.SerializedTaskQueue$MultithreadedTaskProcessor.run(SerializedTaskQueue.java:189)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I use the xSocket 2.8.15 version(jar). The error can be defined as
follows. I have number of INonBlockingConnection object and when I try
to write some data by using the nbc.write() I get an error as defined
above. I do not have any idea about the problem. I try to find
solution by searching the API and mailing list.But I do not find any
satisfied solution. I need some help.I am waiting your advice.
S.U
|
|
From: Mohamad A. A. <az...@gm...> - 2011-03-05 07:09:35
|
Hello,
May I know where i can get the latest version of xSocket 1.2
downloadable source?
I don't want to upgrade to version 2, because it would break existing
codes and it's a live system.
The older one fixed the pool size to 250 which is causing memory issue
on my production system, and I noticed the latest version 1.2.x is still
fixed it at 40. There is no way to configure it.
private static final ExecutorService newServerWorkerPool() {
return Executors.newFixedThreadPool(250);
}
Many thanks.
Regards,
Azri.
|
|
From: <da...@id...> - 2011-02-11 13:49:14
|
Hi,
Does anybody have an idea about this performance issue? I am really
under a lot of pressure to deliver on a project and while I love the
flexibility that XSocket gives us for the project, I cannot fully
recommend it due to the performance issues I am seeing. Can someone
please help?
Thanks,
Dayne
On Thu, 10 Feb 2011 13:36:23 +0000, <da...@id...> wrote:
> Hi Kasper,
>
> Terribly sorry about the HTML. Below is my post in plain text. The
> issue is not about Netty. I am merely trying to ask if my test case on
> the XSocket side is valid. There seems to be a huge discrepancy between
> the performance of XSocket and Netty. Netty seems to perform much
> better. And because they are both based on Java NIO I find that hard to
> believe. That is why I am asking for some help from the XSocket
> community to see if there is something I am not doing correctly in the
> XSocket test case. I thought that this is what open source communities
> were about, the sharing, collaboration and support of the community.
>
> Best regards,
>
> Dayne
>
> Hi,
>
> I was curious to test the differences between Netty and xLightweb and
> found a strange issue with XlightWeb that I'm hoping someone here can
> help me clear up.
>
> I have setup the following testing environment:
>
> 3 Test machines with the following spec:
>
> 2.2GHz AMD X2 Athlon
> 512MB of RAM
> 8GB HDD
> Sun Java JRE 6 update 22
> Ubuntu 10.04 Server
> fs.file-max = 100000
> net.ipv4.tcp_tw_recycle = 1
> security limits set nofile = 100000 for all users and root
>
> One system is running the Netty 3.2.2 simple HTTP server
> One system is running the xLightweb 2.13.2 simple HTTP server
> One system is running httperf (This is the test client machine)
>
> XSocket Sample code:
>
>
> package com.example.server;
>
> import org.xlightweb.HttpResponse;
> import org.xlightweb.IHttpExchange;
> import org.xlightweb.IHttpRequest;
> import org.xlightweb.IHttpRequestHandler;
> import org.xlightweb.IHttpResponse;
> import org.xlightweb.server.HttpServer;
>
> import java.io.IOException;
>
> /**
> * @author Dayne Lucas
> */
> public class XLightWeb
> {
> public static void main(String[] args) throws Exception
> {
> final HttpServer server = new HttpServer(8007, new
> MethodInfoHandler());
>
> new Thread()
> {
> @Override
> public void run()
> {
> while (!server.isOpen())
> {
> try
> {
> Thread.sleep(1000);
> }
> catch (InterruptedException e)
> {
> // Ignore.
> }
> }
>
> System.out.println("xLightweb EchoServer is ready to serve
> at port " + 8007 + ".");
> }
> }.start();
>
> server.run();
> }
>
> private static final class MethodInfoHandler implements
> IHttpRequestHandler
> {
> public void onRequest(IHttpExchange iHttpExchange) throws
> IOException
> {
> IHttpRequest req = iHttpExchange.getRequest();
>
> IHttpResponse response = new HttpResponse("text/plain",
> "Method called=" + req.getMethod());
>
> iHttpExchange.send(response);
> }
> }
> }
>
>
> Netty sample code:
>
> package com.example.server;
>
> import org.jboss.netty.bootstrap.ServerBootstrap;
> import org.jboss.netty.buffer.ChannelBuffers;
> import org.jboss.netty.channel.ChannelFuture;
> import org.jboss.netty.channel.ChannelFutureListener;
> import org.jboss.netty.channel.ChannelHandlerContext;
> import org.jboss.netty.channel.ChannelPipeline;
> import org.jboss.netty.channel.ChannelPipelineFactory;
> import org.jboss.netty.channel.Channels;
> import org.jboss.netty.channel.ExceptionEvent;
> import org.jboss.netty.channel.MessageEvent;
> import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
> import org.jboss.netty.channel.StaticChannelPipeline;
> import
> org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
> import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
> import org.jboss.netty.handler.codec.http.HttpRequest;
> import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
> import org.jboss.netty.handler.codec.http.HttpResponse;
> import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
> import org.jboss.netty.handler.codec.http.HttpResponseStatus;
> import org.jboss.netty.handler.codec.http.HttpVersion;
> import org.jboss.netty.util.CharsetUtil;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> import java.net.InetSocketAddress;
> import java.util.concurrent.Executors;
>
> /**
> * @author Dayne Lucas
> */
> public class NettyEcho
> {
> public static void main(String[] args)
> {
> // Configure the server.
> final ServerBootstrap bootstrap = new ServerBootstrap(
> new NioServerSocketChannelFactory(
> Executors.newCachedThreadPool(),
> Executors.newCachedThreadPool()));
> // Set up the pipeline factory.
> bootstrap.setPipelineFactory(new ChannelPipelineFactory()
> {
> public ChannelPipeline getPipeline() throws Exception
> {
> HttpRequestDecoder decoder = new HttpRequestDecoder();
> HttpResponseEncoder encoder = new HttpResponseEncoder();
> EchoServerHandler echoServerHandler = new
> EchoServerHandler();
>
> return new StaticChannelPipeline(decoder, encoder,
> echoServerHandler);
> }
>
> });
> // Bind and start to accept incoming connections.
> bootstrap.bind(new InetSocketAddress(8007));
>
> Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
> {
> public void run()
> {
> bootstrap.releaseExternalResources();
> }
> }));
> }
>
> private static final class EchoServerHandler extends
> SimpleChannelUpstreamHandler
> {
> private static final Logger logger = LoggerFactory.getLogger(
> EchoServerHandler.class.getName());
>
> public void messageReceived(ChannelHandlerContext ctx,
> MessageEvent e)
> {
> HttpRequest req = (HttpRequest) e.getMessage();
>
> boolean keepAlive = isKeepAlive(req);
>
> HttpResponse response = new
> DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
> String content = "Method called=" + req.getMethod().getName();
> response.setContent(ChannelBuffers.copiedBuffer(content,
> CharsetUtil.UTF_8));
>
> ChannelFuture write = e.getChannel().write(response);
> if(!keepAlive)
> {
> write.addListener(ChannelFutureListener.CLOSE);
> }
> }
>
> public void exceptionCaught(ChannelHandlerContext ctx,
> ExceptionEvent e)
> {
> // Close the connection when an exception is raised.
> logger.warn("Unexpected exception from downstream.",
> e.getCause());
> e.getChannel().close();
> }
>
> }
> }
>
>
>
> When hitting the XLightWeb server with more than 30000 connections it
> fails and CPU and Memory consumption is through the roof. However with
> the Netty server it can handle far more 60000+ connections without
> batting an eye (CPU and Memory are low).
>
> Is the test case for XSocket incorrect? Am I not closing something I
> should?
>
> Any help would be appreciated.
>
> Best regards,
>
> Dayne
>
>
> On Thu, 10 Feb 2011 13:01:50 +0100, Kasper Grubbe wrote:
>
> You ask a Netty related problem on the xsocket mailinglist.
>
> And your mail is filled with disgusting HTML-code which make your
> posting
> unreadable.
>
> Fix your message and think about whether you want to post it here, or
> in
> the Netty community.
>
> Thanks,
> --
> Kasper Grubbe
> Computer Science AP
>
> Phone: (+45) 42 42 42 74
> Mail: kas...@gm... [1]
>
> On Thu, Feb 10, 2011 at 11:57 AM, wrote:
>
> I was curious to test the differences between Netty and xLightweb
> and found a strange issue with Netty that I'm hoping someone here can
> help me clear up.
>
> I have setup the following testing
> environment:
>
> 3 Test machines with the following spec:
>
> />
> 2.2GHz AMD X2 Athlon
> 512MB of RAM
> 8GB HDD
> Sun
> Java JRE 6 update 22
> Ubuntu 10.04 Server
> fs.file-max =
> 100000
> net.ipv4.tcp_tw_recycle = 1
> security limits set
> nofile = 100000 for all users and root
>
> One system is
> running the Netty 3.2.2 simple HTTP server
> One system is running
> the xLightweb 2.13.2 simple HTTP server
> One system is running
> httperf (This is the test client machine)
>
> Sample code:
>
> XSocket:
>
> package com.example.server;
>
> import
> org.xlightweb.HttpResponse;
> import org.xlightweb.IHttpExchange;
>
> />import org.xlightweb.IHttpRequest;
> import
> org.xlightweb.IHttpRequestHandler;
> import
> org.xlightweb.IHttpResponse;
> import
> org.xlightweb.server.HttpServer;
>
> import
> java.io.IOException;
>
> /**
> * @author Brendt
> Lucas
> */
> public class XLightWeb
> {
>
> /> public static void main(String[] args) throws
> Exception
> {
> final
> HttpServer server = new HttpServer(8007, new MethodInfoHandler());
>
> />
> new Thread()
>
> /> {
>
> /> @Override
>
> /> public void run()
>
> /> {
>
> />
> while (!server.isOpen())
>
> />
> {
>
> />
> try
>
> />
> {
>
> />
> Thread.sleep(1000);
>
> />
> }
>
> />
> catch (InterruptedException e)
>
> />
> {
>
> />
> // Ignore.
>
> />
> }
>
> />
> }
>
> />
> System.out.println("xLightweb EchoServer is ready to serve at port " +
> 8007 + ".");
> }
>
> /> }.start();
>
> /> server.run();
> }
>
> />
> private static final class MethodInfoHandler
> implements IHttpRequestHandler
> {
>
> /> public void onRequest(IHttpExchange
> iHttpExchange) throws IOException
>
> {
> IHttpRequest
> req = iHttpExchange.getRequest();
>
> /> IHttpResponse
> response = new HttpResponse("text/plain", "Method called=" +
> req.getMethod());
>
> />
> iHttpExchange.send(response);
> }
>
> /> }
> }
>
> Netty:
>
> package com.example.server;
>
> import
> org.jboss.netty.bootstrap.ServerBootstrap;
> import
> org.jboss.netty.buffer.ChannelBuffers;
> import
> org.jboss.netty.channel.ChannelFuture;
> import
> org.jboss.netty.channel.ChannelFutureListener;
> import
> org.jboss.netty.channel.ChannelHandlerContext;
> import
> org.jboss.netty.channel.ChannelPipeline;
> import
> org.jboss.netty.channel.ChannelPipelineFactory;
> import
> org.jboss.netty.channel.Channels;
> import
> org.jboss.netty.channel.ExceptionEvent;
> import
> org.jboss.netty.channel.MessageEvent;
> import
> org.jboss.netty.channel.SimpleChannelUpstreamHandler;
> import
> org.jboss.netty.channel.StaticChannelPipeline;
> import
> org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
>
> />import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
>
> />import org.jboss.netty.handler.codec.http.HttpRequest;
> import
> org.jboss.netty.handler.codec.http.HttpRequestDecoder;
> import
> org.jboss.netty.handler.codec.http.HttpResponse;
> import
> org.jboss.netty.handler.codec.http.HttpResponseEncoder;
> import
> org.jboss.netty.handler.codec.http.HttpResponseStatus;
> import
> org.jboss.netty.handler.codec.http.HttpVersion;
> import
> org.jboss.netty.util.CharsetUtil;
> import org.slf4j.Logger;
>
> />import org.slf4j.LoggerFactory;
>
> import
> java.net.InetSocketAddress;
> import
> java.util.concurrent.Executors;
>
> /**
> * @author
> Brendt Lucas
> */
> public class NettyEcho
> {
>
> /> public static void main(String[] args)
>
> {
> // Configure the server.
>
> /> final ServerBootstrap bootstrap = new
> ServerBootstrap(
>
> new NioServerSocketChannelFactory(
>
> />
> Executors.newCachedThreadPool(),
>
> />
> Executors.newCachedThreadPool()));
>
> // Set up the pipeline factory.
>
> bootstrap.setPipelineFactory(new ChannelPipelineFactory()
>
> /> {
>
> /> public
> ChannelPipeline getPipeline() throws Exception
>
> /> {
>
> />
> HttpRequestDecoder decoder = new HttpRequestDecoder();
>
> />
> HttpResponseEncoder encoder = new HttpResponseEncoder();
>
> />
> EchoServerHandler echoServerHandler = new EchoServerHandler();
>
> />
> return new StaticChannelPipeline(decoder, encoder,
> echoServerHandler);
>
> /> }
>
> /> });
>
> /> // Bind and start to accept incoming
> connections.
> bootstrap.bind(new
> InetSocketAddress(8007));
>
> Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
>
> /> {
>
> /> public void run()
>
> /> {
>
> />
> bootstrap.releaseExternalResources();
>
> /> }
>
> /> }));
> }
>
> /> private static final class EchoServerHandler extends
> SimpleChannelUpstreamHandler
> {
>
> /> private static final Logger logger =
> LoggerFactory.getLogger(
>
> />
> EchoServerHandler.class.getName());
>
> /> public void
> messageReceived(ChannelHandlerContext ctx, MessageEvent e)
>
> /> {
>
> /> HttpRequest req =
> (HttpRequest) e.getMessage();
>
> /> boolean keepAlive =
> isKeepAlive(req);
>
> /> HttpResponse
> response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
> HttpResponseStatus.OK);
>
> /> String content =
> "Method called=" + req.getMethod().getName();
>
> />
> response.setContent(ChannelBuffers.copiedBuffer(content,
> CharsetUtil.UTF_8));
>
> /> ChannelFuture write
> = e.getChannel().write(response);
>
> /> if(!keepAlive)
>
> /> {
>
> />
> write.addListener(ChannelFutureListener.CLOSE);
>
> /> }
>
> /> }
>
> /> public void
> exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
>
> /> {
>
> /> // Close the
> connection when an exception is raised.
>
> />
> logger.warn("Unexpected exception from downstream.", e.getCause());
>
> />
> e.getChannel().close();
> }
>
> /> }
> }
>
> When hitting the Netty server
> with 40000 connections total @ 400 connections a second and 10
> requests per connection it works with no issues and very little CPU or
> memory overhead. However when we hit the XSocket server with the same
> load, CPU sky rockets and memory is heavily used. Also the test has
> several errors ( connection resets etc.) In fact we were able to hit
> the Netty server with more than 40000 connections with ease. I was
> wondering if there was something I was doing wrong in the XSocket code
> that could be causing the poor performance?
>
> Any help would
> be appreciated.
>
> Best regards,
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio
> XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb [3]
> _______________________________________________
> xSocket-develop mailing list
> xSo...@li... [4]
> https://lists.sourceforge.net/lists/listinfo/xsocket-develop [5]
>
>
>
> Links:
> ------
> [1] mailto:kas...@gm...
> [2] mailto:da...@id...
> [3] http://p.sf.net/sfu/intel-dev2devfeb
> [4] mailto:xSo...@li...
> [5] https://lists.sourceforge.net/lists/listinfo/xsocket-develop
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> xSocket-develop mailing list
> xSo...@li...
> https://lists.sourceforge.net/lists/listinfo/xsocket-develop
|
|
From: <da...@id...> - 2011-02-10 13:36:40
|
Hi Kasper,
Terribly sorry about the HTML. Below is my post in plain text. The
issue is not about Netty. I am merely trying to ask if my test case on
the XSocket side is valid. There seems to be a huge discrepancy between
the performance of XSocket and Netty. Netty seems to perform much
better. And because they are both based on Java NIO I find that hard to
believe. That is why I am asking for some help from the XSocket
community to see if there is something I am not doing correctly in the
XSocket test case. I thought that this is what open source communities
were about, the sharing, collaboration and support of the community.
Best regards,
Dayne
Hi,
I was curious to test the differences between Netty and xLightweb and
found a strange issue with XlightWeb that I'm hoping someone here can
help me clear up.
I have setup the following testing environment:
3 Test machines with the following spec:
2.2GHz AMD X2 Athlon
512MB of RAM
8GB HDD
Sun Java JRE 6 update 22
Ubuntu 10.04 Server
fs.file-max = 100000
net.ipv4.tcp_tw_recycle = 1
security limits set nofile = 100000 for all users and root
One system is running the Netty 3.2.2 simple HTTP server
One system is running the xLightweb 2.13.2 simple HTTP server
One system is running httperf (This is the test client machine)
XSocket Sample code:
package com.example.server;
import org.xlightweb.HttpResponse;
import org.xlightweb.IHttpExchange;
import org.xlightweb.IHttpRequest;
import org.xlightweb.IHttpRequestHandler;
import org.xlightweb.IHttpResponse;
import org.xlightweb.server.HttpServer;
import java.io.IOException;
/**
* @author Dayne Lucas
*/
public class XLightWeb
{
public static void main(String[] args) throws Exception
{
final HttpServer server = new HttpServer(8007, new
MethodInfoHandler());
new Thread()
{
@Override
public void run()
{
while (!server.isOpen())
{
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
// Ignore.
}
}
System.out.println("xLightweb EchoServer is ready to serve
at port " + 8007 + ".");
}
}.start();
server.run();
}
private static final class MethodInfoHandler implements
IHttpRequestHandler
{
public void onRequest(IHttpExchange iHttpExchange) throws
IOException
{
IHttpRequest req = iHttpExchange.getRequest();
IHttpResponse response = new HttpResponse("text/plain",
"Method called=" + req.getMethod());
iHttpExchange.send(response);
}
}
}
Netty sample code:
package com.example.server;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelFutureListener;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.channel.StaticChannelPipeline;
import
org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.util.CharsetUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
/**
* @author Dayne Lucas
*/
public class NettyEcho
{
public static void main(String[] args)
{
// Configure the server.
final ServerBootstrap bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
// Set up the pipeline factory.
bootstrap.setPipelineFactory(new ChannelPipelineFactory()
{
public ChannelPipeline getPipeline() throws Exception
{
HttpRequestDecoder decoder = new HttpRequestDecoder();
HttpResponseEncoder encoder = new HttpResponseEncoder();
EchoServerHandler echoServerHandler = new
EchoServerHandler();
return new StaticChannelPipeline(decoder, encoder,
echoServerHandler);
}
});
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress(8007));
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
{
public void run()
{
bootstrap.releaseExternalResources();
}
}));
}
private static final class EchoServerHandler extends
SimpleChannelUpstreamHandler
{
private static final Logger logger = LoggerFactory.getLogger(
EchoServerHandler.class.getName());
public void messageReceived(ChannelHandlerContext ctx,
MessageEvent e)
{
HttpRequest req = (HttpRequest) e.getMessage();
boolean keepAlive = isKeepAlive(req);
HttpResponse response = new
DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
String content = "Method called=" + req.getMethod().getName();
response.setContent(ChannelBuffers.copiedBuffer(content,
CharsetUtil.UTF_8));
ChannelFuture write = e.getChannel().write(response);
if(!keepAlive)
{
write.addListener(ChannelFutureListener.CLOSE);
}
}
public void exceptionCaught(ChannelHandlerContext ctx,
ExceptionEvent e)
{
// Close the connection when an exception is raised.
logger.warn("Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
}
}
}
When hitting the XLightWeb server with more than 30000 connections it
fails and CPU and Memory consumption is through the roof. However with
the Netty server it can handle far more 60000+ connections without
batting an eye (CPU and Memory are low).
Is the test case for XSocket incorrect? Am I not closing something I
should?
Any help would be appreciated.
Best regards,
Dayne
On Thu, 10 Feb 2011 13:01:50 +0100, Kasper Grubbe wrote:
You ask a Netty related problem on the xsocket mailinglist.
And your mail is filled with disgusting HTML-code which make your
posting
unreadable.
Fix your message and think about whether you want to post it here, or
in
the Netty community.
Thanks,
--
Kasper Grubbe
Computer Science AP
Phone: (+45) 42 42 42 74
Mail: kas...@gm... [1]
On Thu, Feb 10, 2011 at 11:57 AM, wrote:
I was curious to test the differences between Netty and xLightweb
and found a strange issue with Netty that I'm hoping someone here can
help me clear up.
I have setup the following testing
environment:
3 Test machines with the following spec:
/>
2.2GHz AMD X2 Athlon
512MB of RAM
8GB HDD
Sun
Java JRE 6 update 22
Ubuntu 10.04 Server
fs.file-max =
100000
net.ipv4.tcp_tw_recycle = 1
security limits set
nofile = 100000 for all users and root
One system is
running the Netty 3.2.2 simple HTTP server
One system is running
the xLightweb 2.13.2 simple HTTP server
One system is running
httperf (This is the test client machine)
Sample code:
XSocket:
package com.example.server;
import
org.xlightweb.HttpResponse;
import org.xlightweb.IHttpExchange;
/>import org.xlightweb.IHttpRequest;
import
org.xlightweb.IHttpRequestHandler;
import
org.xlightweb.IHttpResponse;
import
org.xlightweb.server.HttpServer;
import
java.io.IOException;
/**
* @author Brendt
Lucas
*/
public class XLightWeb
{
/> public static void main(String[] args) throws
Exception
{
final
HttpServer server = new HttpServer(8007, new MethodInfoHandler());
/>
new Thread()
/> {
/> @Override
/> public void run()
/> {
/>
while (!server.isOpen())
/>
{
/>
try
/>
{
/>
Thread.sleep(1000);
/>
}
/>
catch (InterruptedException e)
/>
{
/>
// Ignore.
/>
}
/>
}
/>
System.out.println("xLightweb EchoServer is ready to serve at port " +
8007 + ".");
}
/> }.start();
/> server.run();
}
/>
private static final class MethodInfoHandler
implements IHttpRequestHandler
{
/> public void onRequest(IHttpExchange
iHttpExchange) throws IOException
{
IHttpRequest
req = iHttpExchange.getRequest();
/> IHttpResponse
response = new HttpResponse("text/plain", "Method called=" +
req.getMethod());
/>
iHttpExchange.send(response);
}
/> }
}
Netty:
package com.example.server;
import
org.jboss.netty.bootstrap.ServerBootstrap;
import
org.jboss.netty.buffer.ChannelBuffers;
import
org.jboss.netty.channel.ChannelFuture;
import
org.jboss.netty.channel.ChannelFutureListener;
import
org.jboss.netty.channel.ChannelHandlerContext;
import
org.jboss.netty.channel.ChannelPipeline;
import
org.jboss.netty.channel.ChannelPipelineFactory;
import
org.jboss.netty.channel.Channels;
import
org.jboss.netty.channel.ExceptionEvent;
import
org.jboss.netty.channel.MessageEvent;
import
org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import
org.jboss.netty.channel.StaticChannelPipeline;
import
org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
/>import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
/>import org.jboss.netty.handler.codec.http.HttpRequest;
import
org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import
org.jboss.netty.handler.codec.http.HttpResponse;
import
org.jboss.netty.handler.codec.http.HttpResponseEncoder;
import
org.jboss.netty.handler.codec.http.HttpResponseStatus;
import
org.jboss.netty.handler.codec.http.HttpVersion;
import
org.jboss.netty.util.CharsetUtil;
import org.slf4j.Logger;
/>import org.slf4j.LoggerFactory;
import
java.net.InetSocketAddress;
import
java.util.concurrent.Executors;
/**
* @author
Brendt Lucas
*/
public class NettyEcho
{
/> public static void main(String[] args)
{
// Configure the server.
/> final ServerBootstrap bootstrap = new
ServerBootstrap(
new NioServerSocketChannelFactory(
/>
Executors.newCachedThreadPool(),
/>
Executors.newCachedThreadPool()));
// Set up the pipeline factory.
bootstrap.setPipelineFactory(new ChannelPipelineFactory()
/> {
/> public
ChannelPipeline getPipeline() throws Exception
/> {
/>
HttpRequestDecoder decoder = new HttpRequestDecoder();
/>
HttpResponseEncoder encoder = new HttpResponseEncoder();
/>
EchoServerHandler echoServerHandler = new EchoServerHandler();
/>
return new StaticChannelPipeline(decoder, encoder,
echoServerHandler);
/> }
/> });
/> // Bind and start to accept incoming
connections.
bootstrap.bind(new
InetSocketAddress(8007));
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
/> {
/> public void run()
/> {
/>
bootstrap.releaseExternalResources();
/> }
/> }));
}
/> private static final class EchoServerHandler extends
SimpleChannelUpstreamHandler
{
/> private static final Logger logger =
LoggerFactory.getLogger(
/>
EchoServerHandler.class.getName());
/> public void
messageReceived(ChannelHandlerContext ctx, MessageEvent e)
/> {
/> HttpRequest req =
(HttpRequest) e.getMessage();
/> boolean keepAlive =
isKeepAlive(req);
/> HttpResponse
response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
HttpResponseStatus.OK);
/> String content =
"Method called=" + req.getMethod().getName();
/>
response.setContent(ChannelBuffers.copiedBuffer(content,
CharsetUtil.UTF_8));
/> ChannelFuture write
= e.getChannel().write(response);
/> if(!keepAlive)
/> {
/>
write.addListener(ChannelFutureListener.CLOSE);
/> }
/> }
/> public void
exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
/> {
/> // Close the
connection when an exception is raised.
/>
logger.warn("Unexpected exception from downstream.", e.getCause());
/>
e.getChannel().close();
}
/> }
}
When hitting the Netty server
with 40000 connections total @ 400 connections a second and 10
requests per connection it works with no issues and very little CPU or
memory overhead. However when we hit the XSocket server with the same
load, CPU sky rockets and memory is heavily used. Also the test has
several errors ( connection resets etc.) In fact we were able to hit
the Netty server with more than 40000 connections with ease. I was
wondering if there was something I was doing wrong in the XSocket code
that could be causing the poor performance?
Any help would
be appreciated.
Best regards,
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio
XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb [3]
_______________________________________________
xSocket-develop mailing list
xSo...@li... [4]
https://lists.sourceforge.net/lists/listinfo/xsocket-develop [5]
Links:
------
[1] mailto:kas...@gm...
[2] mailto:da...@id...
[3] http://p.sf.net/sfu/intel-dev2devfeb
[4] mailto:xSo...@li...
[5] https://lists.sourceforge.net/lists/listinfo/xsocket-develop
|
|
From: Kasper G. <kaw...@gm...> - 2011-02-10 12:01:57
|
You ask a Netty related problem on the xsocket mailinglist.
And your mail is filled with disgusting HTML-code which make your posting
unreadable.
Fix your message and think about whether you want to post it here, or in the
Netty community.
Thanks,
--
Kasper Grubbe
Computer Science AP
Phone: (+45) 42 42 42 74
Mail: kas...@gm...
On Thu, Feb 10, 2011 at 11:57 AM, <da...@id...> wrote:
> <p>I was curious to test the differences between Netty and xLightweb
> and found a strange issue with Netty that I'm hoping someone here can
> help me clear up. <br /><br />I have setup the following testing
> environment: <br /><br />3 Test machines with the following spec: <br
> /><br />2.2GHz AMD X2 Athlon <br />512MB of RAM <br />8GB HDD <br />Sun
> Java JRE 6 update 22 <br />Ubuntu 10.04 Server <br />fs.file-max =
> 100000 <br />net.ipv4.tcp_tw_recycle = 1 <br />security limits set
> nofile = 100000 for all users and root <br /><br />One system is
> running the Netty 3.2.2 simple HTTP server <br />One system is running
> the xLightweb 2.13.2 simple HTTP server <br />One system is running
> httperf (This is the test client machine) <br /><br />Sample code:</p>
> <p> </p>
> <p>XSocket:</p>
> <p> </p>
> <p>package com.example.server;<br /><br />import
> org.xlightweb.HttpResponse;<br />import org.xlightweb.IHttpExchange;<br
> />import org.xlightweb.IHttpRequest;<br />import
> org.xlightweb.IHttpRequestHandler;<br />import
> org.xlightweb.IHttpResponse;<br />import
> org.xlightweb.server.HttpServer;<br /><br />import
> java.io.IOException;<br /><br />/**<br /> * @author Brendt
> Lucas<br /> */<br />public class XLightWeb<br />{<br
> /> public static void main(String[] args) throws
> Exception<br /> {<br /> final
> HttpServer server = new HttpServer(8007, new MethodInfoHandler());<br
> /><br /> new Thread()<br
> /> {<br
> /> @Override<br
> /> public void run()<br
> /> {<br
> />
> while (!server.isOpen())<br
> />
> {<br
>
> />
> try<br
>
> />
> {<br
>
> />
> Thread.sleep(1000);<br
>
> />
> }<br
>
> />
> catch (InterruptedException e)<br
>
> />
> {<br
>
> />
> // Ignore.<br
>
> />
> }<br
> />
> }<br /><br
> />
> System.out.println("xLightweb EchoServer is ready to serve at port " +
> 8007 + ".");<br /> }<br
> /> }.start();<br /><br
> /> server.run();<br /> }<br
> /><br /> private static final class MethodInfoHandler
> implements IHttpRequestHandler<br /> {<br
> /> public void onRequest(IHttpExchange
> iHttpExchange) throws IOException<br />
> {<br /> IHttpRequest
> req = iHttpExchange.getRequest();<br /><br
> /> IHttpResponse
> response = new HttpResponse("text/plain", "Method called=" +
> req.getMethod());<br /><br
> />
> iHttpExchange.send(response);<br /> }<br
> /> }<br />}<br /><br /></p>
> <p> </p>
> <p>Netty:</p>
> <p> </p>
> <p>package com.example.server;<br /><br />import
> org.jboss.netty.bootstrap.ServerBootstrap;<br />import
> org.jboss.netty.buffer.ChannelBuffers;<br />import
> org.jboss.netty.channel.ChannelFuture;<br />import
> org.jboss.netty.channel.ChannelFutureListener;<br />import
> org.jboss.netty.channel.ChannelHandlerContext;<br />import
> org.jboss.netty.channel.ChannelPipeline;<br />import
> org.jboss.netty.channel.ChannelPipelineFactory;<br />import
> org.jboss.netty.channel.Channels;<br />import
> org.jboss.netty.channel.ExceptionEvent;<br />import
> org.jboss.netty.channel.MessageEvent;<br />import
> org.jboss.netty.channel.SimpleChannelUpstreamHandler;<br />import
> org.jboss.netty.channel.StaticChannelPipeline;<br />import
> org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;<br
> />import org.jboss.netty.handler.codec.http.DefaultHttpResponse;<br
> />import org.jboss.netty.handler.codec.http.HttpRequest;<br />import
> org.jboss.netty.handler.codec.http.HttpRequestDecoder;<br />import
> org.jboss.netty.handler.codec.http.HttpResponse;<br />import
> org.jboss.netty.handler.codec.http.HttpResponseEncoder;<br />import
> org.jboss.netty.handler.codec.http.HttpResponseStatus;<br />import
> org.jboss.netty.handler.codec.http.HttpVersion;<br />import
> org.jboss.netty.util.CharsetUtil;<br />import org.slf4j.Logger;<br
> />import org.slf4j.LoggerFactory;<br /><br />import
> java.net.InetSocketAddress;<br />import
> java.util.concurrent.Executors;<br /><br />/**<br /> * @author
> Brendt Lucas<br /> */<br />public class NettyEcho<br />{<br
> /> public static void main(String[] args)<br />
> {<br /> // Configure the server.<br
> /> final ServerBootstrap bootstrap = new
> ServerBootstrap(<br />
> new NioServerSocketChannelFactory(<br
> />
> Executors.newCachedThreadPool(),<br
> />
> Executors.newCachedThreadPool()));<br />
> // Set up the pipeline factory.<br />
> bootstrap.setPipelineFactory(new ChannelPipelineFactory()<br
> /> {<br
> /> public
> ChannelPipeline getPipeline() throws Exception<br
> /> {<br
> />
> HttpRequestDecoder decoder = new HttpRequestDecoder();<br
> />
> HttpResponseEncoder encoder = new HttpResponseEncoder();<br
> />
> EchoServerHandler echoServerHandler = new EchoServerHandler();<br /><br
> />
> return new StaticChannelPipeline(decoder, encoder,
> echoServerHandler);<br
> /> }<br /><br
> /> });<br
> /> // Bind and start to accept incoming
> connections.<br /> bootstrap.bind(new
> InetSocketAddress(8007));<br /><br />
> Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()<br
> /> {<br
> /> public void run()<br
> /> {<br
> />
> bootstrap.releaseExternalResources();<br
> /> }<br
> /> }));<br /> }<br /><br
> /> private static final class EchoServerHandler extends
> SimpleChannelUpstreamHandler<br /> {<br
> /> private static final Logger logger =
> LoggerFactory.getLogger(<br
> />
> EchoServerHandler.class.getName());<br /><br
> /> public void
> messageReceived(ChannelHandlerContext ctx, MessageEvent e)<br
> /> {<br
> /> HttpRequest req =
> (HttpRequest) e.getMessage();<br /><br
> /> boolean keepAlive =
> isKeepAlive(req);<br /><br
> /> HttpResponse
> response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
> HttpResponseStatus.OK);<br
> /> String content =
> "Method called=" + req.getMethod().getName();<br
> />
> response.setContent(ChannelBuffers.copiedBuffer(content,
> CharsetUtil.UTF_8));<br /><br
> /> ChannelFuture write
> = e.getChannel().write(response);<br
> /> if(!keepAlive)<br
> /> {<br
> />
> write.addListener(ChannelFutureListener.CLOSE);<br
> /> }<br
> /> }<br /><br
> /> public void
> exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)<br
> /> {<br
> /> // Close the
> connection when an exception is raised.<br
> />
> logger.warn("Unexpected exception from downstream.", e.getCause());<br
> />
> e.getChannel().close();<br /> }<br /><br
> /> }<br />}<br /><br /><br />When hitting the Netty server
> with 40000 connections total @ 400 connections a second and 10
> requests per connection it works with no issues and very little CPU or
> memory overhead. However when we hit the XSocket server with the same
> load, CPU sky rockets and memory is heavily used. Also the test has
> several errors ( connection resets etc.) In fact we were able to hit
> the Netty server with more than 40000 connections with ease. I was
> wondering if there was something I was doing wrong in the XSocket code
> that could be causing the poor performance?<br /><br />Any help would
> be appreciated. <br /><br />Best regards,</p>
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> xSocket-develop mailing list
> xSo...@li...
> https://lists.sourceforge.net/lists/listinfo/xsocket-develop
>
|
|
From: <da...@id...> - 2011-02-10 11:18:34
|
<p>I was curious to test the differences between Netty and xLightweb
and found a strange issue with Netty that I'm hoping someone here can
help me clear up. <br /><br />I have setup the following testing
environment: <br /><br />3 Test machines with the following spec: <br
/><br />2.2GHz AMD X2 Athlon <br />512MB of RAM <br />8GB HDD <br />Sun
Java JRE 6 update 22 <br />Ubuntu 10.04 Server <br />fs.file-max =
100000 <br />net.ipv4.tcp_tw_recycle = 1 <br />security limits set
nofile = 100000 for all users and root <br /><br />One system is
running the Netty 3.2.2 simple HTTP server <br />One system is running
the xLightweb 2.13.2 simple HTTP server <br />One system is running
httperf (This is the test client machine) <br /><br />Sample code:</p>
<p> </p>
<p>XSocket:</p>
<p> </p>
<p>package com.example.server;<br /><br />import
org.xlightweb.HttpResponse;<br />import org.xlightweb.IHttpExchange;<br
/>import org.xlightweb.IHttpRequest;<br />import
org.xlightweb.IHttpRequestHandler;<br />import
org.xlightweb.IHttpResponse;<br />import
org.xlightweb.server.HttpServer;<br /><br />import
java.io.IOException;<br /><br />/**<br /> * @author Brendt
Lucas<br /> */<br />public class XLightWeb<br />{<br
/> public static void main(String[] args) throws
Exception<br /> {<br /> final
HttpServer server = new HttpServer(8007, new MethodInfoHandler());<br
/><br /> new Thread()<br
/> {<br
/> @Override<br
/> public void run()<br
/> {<br
/>
while (!server.isOpen())<br
/>
{<br
/>
try<br
/>
{<br
/>
Thread.sleep(1000);<br
/>
}<br
/>
catch (InterruptedException e)<br
/>
{<br
/>
// Ignore.<br
/>
}<br
/>
}<br /><br
/>
System.out.println("xLightweb EchoServer is ready to serve at port " +
8007 + ".");<br /> }<br
/> }.start();<br /><br
/> server.run();<br /> }<br
/><br /> private static final class MethodInfoHandler
implements IHttpRequestHandler<br /> {<br
/> public void onRequest(IHttpExchange
iHttpExchange) throws IOException<br />
{<br /> IHttpRequest
req = iHttpExchange.getRequest();<br /><br
/> IHttpResponse
response = new HttpResponse("text/plain", "Method called=" +
req.getMethod());<br /><br
/>
iHttpExchange.send(response);<br /> }<br
/> }<br />}<br /><br /></p>
<p> </p>
<p>Netty:</p>
<p> </p>
<p>package com.example.server;<br /><br />import
org.jboss.netty.bootstrap.ServerBootstrap;<br />import
org.jboss.netty.buffer.ChannelBuffers;<br />import
org.jboss.netty.channel.ChannelFuture;<br />import
org.jboss.netty.channel.ChannelFutureListener;<br />import
org.jboss.netty.channel.ChannelHandlerContext;<br />import
org.jboss.netty.channel.ChannelPipeline;<br />import
org.jboss.netty.channel.ChannelPipelineFactory;<br />import
org.jboss.netty.channel.Channels;<br />import
org.jboss.netty.channel.ExceptionEvent;<br />import
org.jboss.netty.channel.MessageEvent;<br />import
org.jboss.netty.channel.SimpleChannelUpstreamHandler;<br />import
org.jboss.netty.channel.StaticChannelPipeline;<br />import
org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;<br
/>import org.jboss.netty.handler.codec.http.DefaultHttpResponse;<br
/>import org.jboss.netty.handler.codec.http.HttpRequest;<br />import
org.jboss.netty.handler.codec.http.HttpRequestDecoder;<br />import
org.jboss.netty.handler.codec.http.HttpResponse;<br />import
org.jboss.netty.handler.codec.http.HttpResponseEncoder;<br />import
org.jboss.netty.handler.codec.http.HttpResponseStatus;<br />import
org.jboss.netty.handler.codec.http.HttpVersion;<br />import
org.jboss.netty.util.CharsetUtil;<br />import org.slf4j.Logger;<br
/>import org.slf4j.LoggerFactory;<br /><br />import
java.net.InetSocketAddress;<br />import
java.util.concurrent.Executors;<br /><br />/**<br /> * @author
Brendt Lucas<br /> */<br />public class NettyEcho<br />{<br
/> public static void main(String[] args)<br />
{<br /> // Configure the server.<br
/> final ServerBootstrap bootstrap = new
ServerBootstrap(<br />
new NioServerSocketChannelFactory(<br
/>
Executors.newCachedThreadPool(),<br
/>
Executors.newCachedThreadPool()));<br />
// Set up the pipeline factory.<br />
bootstrap.setPipelineFactory(new ChannelPipelineFactory()<br
/> {<br
/> public
ChannelPipeline getPipeline() throws Exception<br
/> {<br
/>
HttpRequestDecoder decoder = new HttpRequestDecoder();<br
/>
HttpResponseEncoder encoder = new HttpResponseEncoder();<br
/>
EchoServerHandler echoServerHandler = new EchoServerHandler();<br /><br
/>
return new StaticChannelPipeline(decoder, encoder,
echoServerHandler);<br
/> }<br /><br
/> });<br
/> // Bind and start to accept incoming
connections.<br /> bootstrap.bind(new
InetSocketAddress(8007));<br /><br />
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()<br
/> {<br
/> public void run()<br
/> {<br
/>
bootstrap.releaseExternalResources();<br
/> }<br
/> }));<br /> }<br /><br
/> private static final class EchoServerHandler extends
SimpleChannelUpstreamHandler<br /> {<br
/> private static final Logger logger =
LoggerFactory.getLogger(<br
/>
EchoServerHandler.class.getName());<br /><br
/> public void
messageReceived(ChannelHandlerContext ctx, MessageEvent e)<br
/> {<br
/> HttpRequest req =
(HttpRequest) e.getMessage();<br /><br
/> boolean keepAlive =
isKeepAlive(req);<br /><br
/> HttpResponse
response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
HttpResponseStatus.OK);<br
/> String content =
"Method called=" + req.getMethod().getName();<br
/>
response.setContent(ChannelBuffers.copiedBuffer(content,
CharsetUtil.UTF_8));<br /><br
/> ChannelFuture write
= e.getChannel().write(response);<br
/> if(!keepAlive)<br
/> {<br
/>
write.addListener(ChannelFutureListener.CLOSE);<br
/> }<br
/> }<br /><br
/> public void
exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)<br
/> {<br
/> // Close the
connection when an exception is raised.<br
/>
logger.warn("Unexpected exception from downstream.", e.getCause());<br
/>
e.getChannel().close();<br /> }<br /><br
/> }<br />}<br /><br /><br />When hitting the Netty server
with 40000 connections total @ 400 connections a second and 10
requests per connection it works with no issues and very little CPU or
memory overhead. However when we hit the XSocket server with the same
load, CPU sky rockets and memory is heavily used. Also the test has
several errors ( connection resets etc.) In fact we were able to hit
the Netty server with more than 40000 connections with ease. I was
wondering if there was something I was doing wrong in the XSocket code
that could be causing the poor performance?<br /><br />Any help would
be appreciated. <br /><br />Best regards,</p>
|
|
From: Cyril W. <cwa...@ax...> - 2011-02-03 09:25:11
|
Hello,
I'd like to know if xSocket is compatible with Java 6. I've been using
xSocket 2.5 with Java 1.5 for quite a while and I'd like first of all to
thank the community for that.
However, I have issues with Java6. I'm not completely sure if that's related
to Java 6 but here is the deal.
I instantiate a Server using the following code snippet:
SSLContext context = SSLContext.getInstance("TLS");
// Initialize custom keyManagers and trustManagers here.
context.init(keyManagers, trustManagers, new SecureRandom());
IServer server = new Server(port, new ASN1Handler(), context, true);
server.start();
No matter what I do, I get the following error message in the log file when
a client tries to connect.
2011-02-02 18:53:29,294 - [xDispatcherSrv7101#0] INFO
(SystemUtil.print:205) - Compression Methods: {
2011-02-02 18:53:29,294 - [xDispatcherSrv7101#0] INFO
(SystemUtil.println:210) - }
2011-02-02 18:53:29,294 - [xDispatcherSrv7101#0] INFO
(SystemUtil.println:210) - ***
2011-02-02 18:53:29,295 - [xDispatcherSrv7101#0] INFO
(SystemUtil.println:210) - xDispatcherSrv7101#0, fatal error: 40: no cipher
suites in common
javax.net.ssl.SSLHandshakeException: no cipher suites in common
2011-02-02 18:53:29,295 - [xDispatcherSrv7101#0] INFO
(SystemUtil.print:205) - xDispatcherSrv7101#0
2011-02-02 18:53:29,295 - [xDispatcherSrv7101#0] INFO
(SystemUtil.print:205) - , SEND TLSv1 ALERT:
2011-02-02 18:53:29,296 - [xDispatcherSrv7101#0] INFO
(SystemUtil.print:205) - fatal,
2011-02-02 18:53:29,296 - [xDispatcherSrv7101#0] INFO
(SystemUtil.println:210) - description = handshake_failure
2011-02-02 18:53:29,296 - [xDispatcherSrv7101#0] INFO
(SystemUtil.println:210) - xDispatcherSrv7101#0, WRITE: TLSv1 Alert, length
= 2
2011-02-02 18:53:29,297 - [xDispatcherSrv7101#0] INFO
(SystemUtil.println:210) - xDispatcherSrv7101#0, fatal: engine already
closed. Rethrowing javax.net.ssl.SSLHandshakeException: no cipher suites in
common
2011-02-02 18:53:29,575 - [xWorkerPool-1-thread-2] INFO
(SystemUtil.println:210) - [Raw write]: length = 7
2011-02-02 18:53:33,226 - [HeartbeatUpdater] DEBUG
(HeartbeatUpdater.updateHeartbeat:82) - Updating heartbeat
2011-02-02 18:53:33,227 - [xServer:7101] INFO (SystemUtil.println:210) -
xServer:7101, fatal: engine already closed. Rethrowing
javax.net.ssl.SSLException: SSLEngine is closing/closed
2011-02-02 18:53:33,231 - [xServer:7101] WARN (IoAcceptor.publish:18) -
(org.xsocket.connection.IoAcceptor.accept) - error occured while accepting
connection: java.lang.RuntimeException: javax.net.ssl.SSLException:
SSLEngine is closing/closed
at org.xsocket.connection.IoSSLProcessor.start(IoSSLProcessor.java:161)
at org.xsocket.connection.IoSSLHandler.startSSL(IoSSLHandler.java:155)
at org.xsocket.connection.IoSSLHandler.init(IoSSLHandler.java:95)
at
org.xsocket.connection.NonBlockingConnection.init(NonBlockingConnection.java
:1049)
at
org.xsocket.connection.NonBlockingConnection.init(NonBlockingConnection.java
:1043)
at org.xsocket.connection.Server$LifeCycleHandler.init(Server.java:1191)
at
org.xsocket.connection.Server$LifeCycleHandler.onConnectionAccepted(Server.j
ava:1171)
at org.xsocket.connection.IoAcceptor.accept(IoAcceptor.java:223)
at org.xsocket.connection.IoAcceptor.listen(IoAcceptor.java:206)
at org.xsocket.connection.Server.run(Server.java:603)
at java.lang.Thread.run(Thread.java:680)
Caused by: javax.net.ssl.SSLException: SSLEngine is closing/closed
at
com.sun.net.ssl.internal.ssl.SSLEngineImpl.kickstartHandshake(SSLEngineImpl.
java:656)
at
com.sun.net.ssl.internal.ssl.SSLEngineImpl.beginHandshake(SSLEngineImpl.java
:689)
at org.xsocket.connection.IoSSLProcessor.start(IoSSLProcessor.java:159)
... 10 more
I spent some time monkeying in debug mode to make sure that client and
server have indeed a common cipher suite. I also tried overriding the cipher
suite in IoSSLProcessor by setting the SystemProperty
"org.xsocket.connection.server.ssl.sslengine.enabledCipherSuites" but
without any luck.
Whatever I do, my custom X509ExtendedKeyManager is never called for the
server certificate and private key.
I tracked it down to IoSSLProcessor:start:159 where it calls
sslEngine.beginHandshake(). That sslEngine is retrieved from the sslContext
provided above. The sslEngine is the Sun sslEngineImpl which unfortunately I
don't have the sources to go further.
The exact same code was working just fine with Java 5 and xSocket 2.5. I
obviously tried the combination xSocket 2.5 and Java 6 first and since that
didn't work, I upgraded to the latest version, hoping that this may have
been fixed.
I'm running out of ideas now so I'm turning to you guys. Did you guys
encounter any compatibility issue with Java 6 or better did you guys run
into the same issue?
Thanks.
Best regards,
Cyril Wattebled
|