Re: How to set ssh-dss, 3des-cbc, diffie_hellman_group1_sha1?

2023-03-17 Thread Jon Madsen
This is not exactly what you need but something that I did to get around a 
similar problem:


   SshClient client = SshClient.setUpDefaultClient();

// Get the current default list of key exchange factories
List keyExchangeFactories = 
client.getKeyExchangeFactories();

// Add the Diffie-Hellman-group1-sha1 key exchange factory
keyExchangeFactories.addAll(NamedFactory.setUpTransformedFactories(
false,
List.of(BuiltinDHFactories.dhg1),
ClientBuilder.DH2KEX
));

// Update the key exchange factories
client.setKeyExchangeFactories(keyExchangeFactories);


// Update ciphers
List> cipherFactories = client.getCipherFactories();
List ciphers = new ArrayList<>();

ciphers.add(BuiltinCiphers.blowfishcbc);
ciphers.add(BuiltinCiphers.tripledescbc);

cipherFactories.addAll(NamedFactory.setUpBuiltinFactories(false, ciphers));

// Update the cipher exchange factories
client.setCipherFactories(cipherFactories);


From: Luciano Moretti 
Date: Friday, March 17, 2023 at 3:19 PM
To: users@mina.apache.org 
Subject: How to set ssh-dss, 3des-cbc, diffie_hellman_group1_sha1?
[External email: Use caution with links and attachments]





I've got an older device I'm trying to connect to that uses these old
settings.
The main web page indicates that these are supported, but I can't seem to
figure out how to enable them after calling SshClient.setUpDefaultClient()

Digging through the JavaDoc and code for SshClient doesn't make it obvious.

Could someone send me sample code? I looked at Stack Overflow and found
this exact question without an answer as well.

Thanks,
Luciano Moretti


Internal


Re: Client support for Diffie-Hellman-group1-sha1 key exchange

2023-02-21 Thread Jon Madsen
Please disregard this issue as I have gotten it to work, and if you read this 
thanks for reading.

Jon

From: Jon Madsen 
Date: Tuesday, February 21, 2023 at 3:25 PM
To: users@mina.apache.org 
Subject: Client support for Diffie-Hellman-group1-sha1 key exchange
Hi all,

I am working on a product that needs to support legacy devices in the field 
that support the old Diffie-hellman-group1-sha1 key exchange.  I am using the 
SshClient with success with all of our other devices, however I am trying to 
figure out the proper way to add support for the dhg1 key exchange.  The 
following is a code excerpt for a my client creation, and my failed attempt to 
add the key exchange, however it does not seem to work quite right.   Any 
thoughts or help is greatly appreciated.


private SshClient createClient() {
SshClient client = SshClient.setUpDefaultClient();

// Get the current default list of key exchange factories
List keyExchangeFactories = 
client.getKeyExchangeFactories();

// Add the Diffie-Hellman-group1-sha1 key exchange factory
keyExchangeFactories.addAll(NamedFactory.setUpTransformedFactories(
false,
List.of(BuiltinDHFactories.dhg1),
ClientBuilder.DH2KEX
));

// Update the factories
client.setKeyExchangeFactories(keyExchangeFactories);

// Dump them just to see what is set
client.getKeyExchangeFactories().stream().forEach(kex -> 
logger.error(String.format("Client session KEX: %s", kex.getName(;
return client;
}


Thanks,

Jon


Internal


Client support for Diffie-Hellman-group1-sha1 key exchange

2023-02-21 Thread Jon Madsen
Hi all,

I am working on a product that needs to support legacy devices in the field 
that support the old Diffie-hellman-group1-sha1 key exchange.  I am using the 
SshClient with success with all of our other devices, however I am trying to 
figure out the proper way to add support for the dhg1 key exchange.  The 
following is a code excerpt for a my client creation, and my failed attempt to 
add the key exchange, however it does not seem to work quite right.   Any 
thoughts or help is greatly appreciated.


private SshClient createClient() {
SshClient client = SshClient.setUpDefaultClient();

// Get the current default list of key exchange factories
List keyExchangeFactories = 
client.getKeyExchangeFactories();

// Add the Diffie-Hellman-group1-sha1 key exchange factory
keyExchangeFactories.addAll(NamedFactory.setUpTransformedFactories(
false,
List.of(BuiltinDHFactories.dhg1),
ClientBuilder.DH2KEX
));

// Update the factories
client.setKeyExchangeFactories(keyExchangeFactories);

// Dump them just to see what is set
client.getKeyExchangeFactories().stream().forEach(kex -> 
logger.error(String.format("Client session KEX: %s", kex.getName(;
return client;
}


Thanks,

Jon


Internal


Re: re : Server Crash

2017-04-27 Thread Jon V.
I retract my previous statement after pulling the source for
CircularQueue.  Guess I'm used to doing illegal things in Java I forget
that most code isn't like that.

On Thu, Apr 27, 2017 at 8:38 AM, Jon V.  wrote:

> It looks like a Mina crash to me.  Probably some kind of Unsafe access.
>
> Can you tell us the exact version of Mina?
>
> On Thu, Apr 27, 2017 at 8:20 AM, Emmanuel Lécharny 
> wrote:
>
>> Hi !
>>
>>
>> seems like I have hard time moderating your message to the users
>> mailinglist... Never mind. here is a copy :
>>
>>
>> > We have a standalone application. It crashed suddenly. The log contains
>> a
>> > class which is found in mina-core jar file. I have attached the crash
>> > report. Please let me know if you could find out any root cause for the
>> > crash. Thank you. server_crash_report.txt
>> >
>> <http://apache-mina.10907.n7.nabble.com/file/n52619/server_c
>> rash_report.txt>
>>
>> First of all, this is a JVM crash, not a MINA crash The fact that the
>> crash occurred while the exacution was in a mina call is incidental.
>>
>> I would strongly to switch to a more recent version of Java, the one you
>> use is quite antiquated and not supported anymore (4 years old, the last
>> supported Java 6 version from Oracle, which has issued 16 released for Java
>> 6).
>>
>> Java 8 is the current version, Java 7 has been EOLed 2 years ago.
>>
>>
>> --
>> Emmanuel Lecharny
>>
>> Symas.com
>> directory.apache.org
>>
>>
>


Re: re : Server Crash

2017-04-27 Thread Jon V.
It looks like a Mina crash to me.  Probably some kind of Unsafe access.

Can you tell us the exact version of Mina?

On Thu, Apr 27, 2017 at 8:20 AM, Emmanuel Lécharny 
wrote:

> Hi !
>
>
> seems like I have hard time moderating your message to the users
> mailinglist... Never mind. here is a copy :
>
>
> > We have a standalone application. It crashed suddenly. The log contains a
> > class which is found in mina-core jar file. I have attached the crash
> > report. Please let me know if you could find out any root cause for the
> > crash. Thank you. server_crash_report.txt
> >
>  crash_report.txt>
>
> First of all, this is a JVM crash, not a MINA crash The fact that the
> crash occurred while the exacution was in a mina call is incidental.
>
> I would strongly to switch to a more recent version of Java, the one you
> use is quite antiquated and not supported anymore (4 years old, the last
> supported Java 6 version from Oracle, which has issued 16 released for Java
> 6).
>
> Java 8 is the current version, Java 7 has been EOLed 2 years ago.
>
>
> --
> Emmanuel Lecharny
>
> Symas.com
> directory.apache.org
>
>


Re: Why are high ports used by SFTP server implementation?

2016-02-23 Thread Jon V.
I’ll try to simplify; TCP (the protocol) can have up to 0x ports or
65535

Ports only need to be reserved for server services and outbound
connections.  They both use the same pool size of 65535.  Each OS type
allocates different range for user-space applications.  For linux its
around 32768 ports.  When creating outbound connections the OS will
randomly select an unused port.  This is this high port number.

A connected TCP socket looks like this: local:45223 (ephemeral) <->
remote:22 (fixed)

What you are seeing is the port number of the client.  That number is
allocated on their machine and not the server.

Look up TCP on Wikipedia.

On Tue, Feb 23, 2016 at 8:52 PM, David Hoffer  wrote:

> Hum, that's not entirely clear to me.  The first link says...
>
> 'A TCP/IPv4 connection consists of two endpoints, and each endpoint
> consists of an IP address and a port number.  Therefore, when a client user
> connects to a server computer, an established connection can be thought of
> as the 4-tuple of (server IP, server port, client IP, client port).
> Usually three of the four are readily known -- client machine uses its own
> IP address and when connecting to a remote service, the server machine's IP
> address and service port number are required.
>
> What is not immediately evident is that when a connection is established
> that the client side of the connection uses a port number.  Unless a client
> program explicitly requests a specific port number, the port number used is
> an *ephemeral* port number.  Ephemeral ports are temporary ports assigned
> by a machine's IP stack, and are assigned from a designated range of ports
> for this purpose.
> In our case the server is configured to listen on port 22 and the client
> connects to port 22 so isn't that fixing the port on both sides at port
> 22?  Are you saying that although port 22 is the logical port used on both
> systems, that in reality a different port is used on the client to connect
> to the server?  We are using SSH only here I understand that only used port
> 22.
>
> Regarding the second link is that for FTP or also for SFTP?  I know FTP
> uses passive ports and so does FTPS but we are only using SFTP, e.g. file
> transfer as part of SSH.
>
> Do those links really describe my situation?  Or are those high ports
> created on the server so it can hand off work so it can listen on 22
> again?  E.g. is it using separate ports to communicate with clients instead
> of multiple threads on same port?
>
> Its not clear to me yet, trying to understand.
>
> -Dave
>
>
>
>
> On Tue, Feb 23, 2016 at 4:32 PM, Chad Beaulac  wrote:
>
> > Hey Dave,
> >
> > Listener servers hand off to ephemeral ports.
> > http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html
> > You need ephemeral ports so a server can start listening on port 22 again
> > while something else is happening.
> >
> > Look here for some configuration options.
> >
> https://mina.apache.org/ftpserver-project/configuration_passive_ports.html
> >
> > -Chad
> >
> >
> > On Tue, Feb 23, 2016 at 3:09 PM, David Hoffer 
> wrote:
> >
> > > We are using SSHD in an application to create an embedded SFTP server
> > which
> > > works fine.  Our clients connect on port 22 and we don't have any issue
> > > with that.
> > >
> > > The problem/question is that our IA folks are complaining that our app
> > also
> > > listens on what appear to be random high ports.  E.g. I see this in our
> > > logs.
> > >
> > > Session username@/127.0.0.1:58118 authenticated
> > > Server session created from /127.0.0.1:58132
> > > Server session created from /127.0.0.1:58139
> > > Server session created from /127.0.0.1:58157
> > >
> > > I see these later log statements are coming from IoSession in
> > > ServerSessionImpl but I don't call this in my code so must be part of
> the
> > > SSHD/MINA framework.
> > >
> > > Why are these high ports being used and do we need them?  If not needed
> > for
> > > SFTP server how can I disable?  If they are needed, why and can I
> control
> > > the exact ports that are used?
> > >
> > > -Dave
> > >
> >
>


Re: one question with max connections

2016-02-17 Thread Jon V.
Probably creating the connections too quickly?  make the TCP backlog
larger.  Default is 10 I believe;  I use 100 in production.

On Wed, Feb 17, 2016 at 6:44 AM, Liu, Li (Nokia - CN/Hangzhou) <
li@nokia.com> wrote:

> Hi Mina
>
> I try to use Mina to handle multiple TCP’s connections
>
> But there are some connections that cannot be handled by Mina under lots
> of connections was opened as below :
> Eg, I try to open 400 TCP’s connections, there are always losing 4 or 5
> connections
>
>
>
> [root@twslave2 test]# netstat -natp | grep 62397
> tcp   *22*  0 :::10.70.81.114:65534   :::
> 10.70.81.106:62397   ESTABLISHED -
> [root@twslave2 test]# netstat -natp | grep 62398
> tcp   22  0 :::10.70.81.114:65534   :::10.70.81.106:62398
> ESTABLISHED -
> [root@twslave2 test]# netstat -natp | grep 62399
> tcp   22  0 :::10.70.81.114:65534   :::10.70.81.106:62399
> ESTABLISHED -
> [root@twslave2 test]# netstat -natp | grep 62400
> tcp   22  0 :::10.70.81.114:65534   :::10.70.81.106:62400
> ESTABLISHED -
> [root@twslave2 test]# netstat -natp | grep 62401
> tcp   22  0 :::10.70.81.114:65534   :::10.70.81.106:62401
> ESTABLISHED -
> [root@twslave2 test]# netstat -natp | grep 62396
> tcp0  0 :::10.70.81.114:65534   :::10.70.81.106:62396
> * ESTABLISHED 12152/java*
> [root@twslave2 test]#
>
> Can you tell me why?
>
>


Re: Deadlock when using SslFilter and ProxyFilter together

2016-02-10 Thread Jon V.
I would have thought the reason SSL Filter needs to be before Proxy is
because the SSL handshaking from the client side would get proxied away
from the SSL Filter.

On Wed, Feb 10, 2016 at 12:57 PM, Emmanuel Lécharny 
wrote:

> Le 10/02/16 18:16, Norbert Irmer a écrit :
> >> Ok, but you can insert teh SslFilter *before* the proxyFilter. Once you
> >> get the ProxyConnector instance, get the connector and do :
> >
> > Well, I am using a patched QuickFixJ version, in which the control flow
> is a bit different.
> >
> > Here is an excerpt from the code they are using:
> >
> >
> >   CompositeIoFilterChainBuilder ioFilterChainBuilder = new
> CompositeIoFilterChainBuilder(
> > userIoFilterChainBuilder);
> >
> > boolean useProxy = proxyType != null && proxyPort > 0 &&
> > socketAddresses[0] instanceof
> InetSocketAddress;
> >
> >
> > SslFilter sslFilter = null;
> > if (sslEnabled) {
> > boolean autoStart = !useProxy;
> > sslFilter = installSslFilter(ioFilterChainBuilder,
> autoStart);
> > }
> >
> >
>  ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME,
> > new ProtocolCodecFilter(new
> FIXProtocolCodecFactory()));
> >
> > if (useProxy) {
> > SocketConnector socketConnector = new
> NioSocketConnector();
> >
>  socketConnector.setFilterChainBuilder(ioFilterChainBuilder);
> > ioConnector = ProtocolFactory.createIoProxyConnector(
> socketConnector,
> > (InetSocketAddress) socketAddresses[0], new
> InetSocketAddress(proxyHost,
> > proxyPort), proxyType, proxyVersion,
> proxyUser, proxyPassword,
> > proxyDomain, proxyWorkstation);
> > } else {
> > ioConnector =
> ProtocolFactory.createIoConnector(socketAddresses[0]);
> > ioConnector.setFilterChainBuilder(ioFilterChainBuilder);
> > }
> >
> > ioHandler = new InitiatorIoHandler(fixSession, sslFilter,
> networkingOptions, eventHandlingStrategy);
> > }
> >
> > private SslFilter installSslFilter(CompositeIoFilterChainBuilder
> ioFilterChainBuilder,
> >boolean autoStart)
> > throws GeneralSecurityException {
> > SslFilter sslFilter = new
> SslFilter(SSLContextFactory.getInstance(keyStoreName,
> > keyStorePassword.toCharArray()), autoStart);
> > if (enableProtocole != null)
> > sslFilter.setEnabledProtocols(enableProtocole);
> > if (cipherSuites != null)
> > sslFilter.setEnabledCipherSuites(cipherSuites);
> > sslFilter.setUseClientMode(true);
> > ioFilterChainBuilder.addLast(SSLSupport.FILTER_NAME,
> sslFilter);
> > return sslFilter;
> > }
> >
> >
> > Sure, with a lot of time, I could possibly rewrite the code, to swap the
> positions of the filters in the filterchain.
> >
> > But  I see little sense in it, since the code is working. The only
> problem I have, is that I get this deadlock after a few minutes or so.
> How can you say the code is working when you get a deadlock ?
>
> As Jon said, having the ProcyFilter *before* the SSLFilter in the chain
> is not the right thing. The reason being that you may perfectly get
> fragmented TCP buffers, and the proxy might not be able to deal with
> de-fragmentation when it comes to encrypted data.
>
> I suggest that you patch teh code to first call the installSslFilter
> method after the proxy has been created, and in the
> installSslFiltermethod, use addFirst() instead of addLast().
>
> Otherwise, you can also check with the latest trunk revision I built
> today to see if it's any better (on http://people.apache.org/~elecharny)
>
>


Re: Deadlock when using SslFilter and ProxyFilter together

2016-02-09 Thread Jon V.
Its my understanding that Read and Write operations are thread-safe and
should never cause deadlocks. (not sure why there are locks in those
filters)

Also, I don’t think SSL should be after Proxy.  You cannot initiate an SSL
session if you proxy the setup routine.  What is the goal in this setup?

Please send us the deadlock thread trace.(You can get it from VisualVM)

On Tue, Feb 9, 2016 at 11:59 AM, Norbert Irmer  wrote:

> Hello,
>
> I detected a deadlock when using Proxies and Ssl together.
>
> The SslFilter and the ProxyFilzter both have synchronized blocks, and when
> sending
> and receiving messages you get deadlocks.
>
> The SslFilter hangs in "sslLock.lock()" in
> "SslHandler.flushScheduledEvents()",
> while the ProxyFilter hangs in "synchronized(handler)" in
> "ProxyFilter.writeData".
>
> That sending and receiving messages with both filters simultaneously leads
> to a deadlock
> is clear, since both filters have locks and data flow direction is
> reversed when reading and writing:
>
> Read direction:   Socket  --> ProxyFilter   ---> SslFilter  -->
> FixProtocol   --> Application
> Write direction:  Socket <-- ProxyFilter  <---  SslFilter  <--
> FixProtocol  <-- Application
>
>
>
>


Re: Can we get message attempted to write

2016-02-02 Thread Jon V.
After the message is converted to ByteBuffer is the WriteRequest triggered
or it a child WriteRequest created for the ByteBuffer?  That would define
if this kind of callback would be possible.

On Tue, Feb 2, 2016 at 7:35 AM, Emmanuel Lécharny 
wrote:

> Le 02/02/16 12:10, Abhijit Bhatode a écrit :
> > Hi,
> >
> > We are using MINA 2.0 M1.
> You should switch to 2.0.11 which has been released last wek... 2.0.0-M1
> is 8 years old !
>
> > Is there a way to get details of message when an
> > exception occurs during write?
>
> It depends...
>
> There are many potential exception you can get, and I suspect you wnat
> to get some information in the exceptionCaught() method in your IoHandler.
>
> If you are lucky, the message is still in the write queue. You can get
> it by using :
>
> WriteRequest writeRequest = session.getWriteRequestQueue().poll(
> session );
>
> if (writeRequest != null) {
> Object message = writeRequest.getMessage();
> }
>
> Otherwise, check the cause.
>
> One other possibility is to store in your session the messages that you
> are sending before writing them, and in the exceptionCaught() method,
> you can most certainly check on the session to see what is the message
> that was the cause. This is, again, not guaranteed, because you may have
> many messages waiting to be sent when you get the exception.
>
>
> Keep in mind that this is asynchonous, so the exceptionCaught event can
> be received way after you tried to write a message.
>
> Last, not least, you will receive a messageSent() event for every single
> message that has successfully sent. You can also use this information to
> detect what is the message causing the problem.
>
>
> In any case, as I said, there are many reson why you would receive an
> exception, and a lot of them might be totally disconnect to the fact
> that you tried to write a message.
>
>
> Wht is your use case ?
>
>
>


Re: SslFilter with autoStart=false

2016-01-28 Thread Jon V.
I understand the tendency for defensive style design.

Auto start option should probably be removed from the SSL Filter.  If OP
wishes to construct the chain at Open() time then calling SSL Filter.open()
manually should initiate the handshake.

  @Override
public void proxySessionOpened(IoSession session) throws Exception {
log.info("proxySessionOpened called");
if (sslFilter != null) {
IoFilter.NextFilter nextFilter = session.getFilterChain().
getNextFilter(sslFilter);
sslFilter.sessionOpened(next, session)
}
}

This seems to me more like a fundamental flow problem of filter
modifications than a design issue with SSL filter.

On Thu, Jan 28, 2016 at 10:45 AM, Emmanuel Lécharny 
wrote:

> Le 28/01/16 15:37, Jon V. a écrit :
> > Sorry, I hit enter and my email sent.
> >
> > IoFilterChain filterChain = session.getFilterChain();
> >
> > if (filterChain == null) {
> > throw new SSLException("No filter chain");
> > }
> >
> >
> > This isn’t necessary.  I think we need to know more about OPs goals
> before
> > adding hacky workarounds.
>
> Hmm, yeah, it's probably over-protective.
>
> With respect to such check, I should first have added a if (session ==
> null), and not having such a check makes teh second check a bit spurious.
>
> We can drop it and only have :
>
> public void initiateHandshake(IoSession session) throws SSLException {
> IoFilter.NextFilter nextFilter =
> session.getFilterChain().getNextFilter(SslFilter.class);
>
> if (nextFilter == null) {
> throw new SSLException("No SSL next filter in the chain");
> }
>
> initiateHandshake(nextFilter, session);
> }
>
> For teh same reason, I don't see any use case where we can't have a
> nextFilter, so the if (nextFilter == null) is also spurious.
>
>
> I may have been hit too many times by pervasive NPE, and I try to catch
> them before they happen...
>


Re: SslFilter with autoStart=false

2016-01-28 Thread Jon V.
Sorry, I hit enter and my email sent.

IoFilterChain filterChain = session.getFilterChain();

if (filterChain == null) {
throw new SSLException("No filter chain");
}


This isn’t necessary.  I think we need to know more about OPs goals before
adding hacky workarounds.

On Thu, Jan 28, 2016 at 9:37 AM, Jon V.  wrote:

> Sounds to me like someone has a secondary filterchain they are trying to
> prime artificially.
>
> So then maybe this isn’t necessary?
>
>
>
> On Thu, Jan 28, 2016 at 9:34 AM, Emmanuel Lécharny 
> wrote:
>
>> Le 28/01/16 15:30, Jon V. a écrit :
>> > In what scenario would the SSL filter be attached but the session has no
>> > filterchain
>>
>> None that I know.
>>
>> It would not make any sense.
>>
>
>


Re: SslFilter with autoStart=false

2016-01-28 Thread Jon V.
Sounds to me like someone has a secondary filterchain they are trying to
prime artificially.

So then maybe this isn’t necessary?



On Thu, Jan 28, 2016 at 9:34 AM, Emmanuel Lécharny 
wrote:

> Le 28/01/16 15:30, Jon V. a écrit :
> > In what scenario would the SSL filter be attached but the session has no
> > filterchain
>
> None that I know.
>
> It would not make any sense.
>


Re: SslFilter with autoStart=false

2016-01-28 Thread Jon V.
In what scenario would the SSL filter be attached but the session has no
filterchain

On Thu, Jan 28, 2016 at 7:40 AM, Emmanuel Lécharny 
wrote:

> Le 28/01/16 13:33, Norbert Irmer a écrit :
> > Your idea, adding a method  "public void initiateHandshake(IoSession
> session)" to the SslFilter class,
> > would be perfectly fine for me.
> >
> > I just tested it, and it works fine. Only thing, perhaps, is, that I
> don't know, if session.getFilterChain
> > can return null, so perhaps some null pointer handling is necessary.
> >
> >
> Yes, actually, I have a better implementation that tests corner cases :
>
> public void initiateHandshake(IoSession session) throws SSLException {
> IoFilterChain filterChain = session.getFilterChain();
>
> if (filterChain == null) {
> throw new SSLException("No filter chain");
> }
>
> IoFilter.NextFilter nextFilter =
> filterChain.getNextFilter(SslFilter.class);
>
> if (nextFilter == null) {
> throw new SSLException("No SSL next filter in the chain");
> }
>
> initiateHandshake(nextFilter, session);
> }
>
>
> This is what I'm going to commit.
>


Mina workflow

2016-01-15 Thread Jon V.
Its been a while since I’ve used Mina and I forgot how the processor model
works.

Can anyone confirm the diagram is correct?


Re: where is ssl filter source code?

2015-12-22 Thread Jon V.
Here https://git1-us-west.apache.org/repos/asf?p=mina.git;a=summary

You can choose which HEAD you want.  trunk is 2 years old so I wouldn’t
look at that.

Here is the “2.0” HEAD
https://git1-us-west.apache.org/repos/asf?p=mina.git;a=tree;h=refs/heads/2.0;hb=refs/heads/2.0

Its 4 days old.

On Tue, Dec 22, 2015 at 2:06 PM, Vic Cekvenich 
wrote:

> Hi Emanuel,
> Yes that works and matches source.
> The magic is switching to that proper branch.
>
> I like to look under the hood.
> Cheers,
> Vic
>
>
> On Tue, Dec 22, 2015 at 1:46 AM, Emmanuel Lécharny 
> wrote:
>
> > Le 22/12/15 05:30, Vic Cekvenich a écrit :
> > > Hi Ben, I think I should check first, before I say things are missing.
> > > And it does appear that way. For example there are packages such as
> > > sslfilter under filter that show up in docs, yet when you check out the
> > > source code and search for those files, they are not there.
> > >
> > > It is my understanding that this mail list is for the mina project, so
> I
> > > guess I'm contacting the mina project that: there is missing source
> code
> > > that is documented on www in snippets and mina is an open source
> project.
> > > I would very much like to access the full source code documented - as
> > > linked by Emanuel:
> > > http://mina.apache.org/mina-project/xref/org/apache/mina/filter
> > > Cheers,
> > > Vic
> >
> > We use git at MINA. Youc an get the full sources doing :
> >
> > git clone http://git-wip-us.apache.org/repos/asf/mina.git mina
> >
> > Now, what you get is the *full* MINA repo, and that includes MINA 3.0,
> > probably not what you want. Here is what you get when you run this
> command
> > :
> >
> > $ git tag
> > 0.8.3
> > 0.8.4
> > ...
> > 2.0.5
> > 2.0.6
> > 2.0.7
> > 2.0.8
> > 2.0.9
> > 3.0.0-M1
> > 3.0.0-M2
> > mina-parent-3.0.0-M1
> >
> >
> > You need to checkout the MINA 2.0.10 tag :
> >
> > $ git checkout -b 2.0.10 2.0.10
> > Switched to a new branch '2.0.10'
> >
> >
> > That will allow you to see the full source used by this tag, and to
> > retreive the file you are looking at :
> >
> > $ find . -name SslFilter.java
> > ./mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
> >
> > I'll update the http://mina.apache.org/mina-project/sources.html page to
> > reflect that.
> >
> > Thanks !
> >
> >
>


Re: where is ssl filter source code?

2015-12-22 Thread Jon V.
Here is the browser for the filters package

https://git1-us-west.apache.org/repos/asf?p=mina.git;a=tree;f=mina-core/src/main/java/org/apache/mina/filter;hb=d0263e8a00cf6e60d18317d1e8899554c53083bc

On Tue, Dec 22, 2015 at 4:46 AM, Emmanuel Lécharny 
wrote:

> Le 22/12/15 05:30, Vic Cekvenich a écrit :
> > Hi Ben, I think I should check first, before I say things are missing.
> > And it does appear that way. For example there are packages such as
> > sslfilter under filter that show up in docs, yet when you check out the
> > source code and search for those files, they are not there.
> >
> > It is my understanding that this mail list is for the mina project, so I
> > guess I'm contacting the mina project that: there is missing source code
> > that is documented on www in snippets and mina is an open source project.
> > I would very much like to access the full source code documented - as
> > linked by Emanuel:
> > http://mina.apache.org/mina-project/xref/org/apache/mina/filter
> > Cheers,
> > Vic
>
> We use git at MINA. Youc an get the full sources doing :
>
> git clone http://git-wip-us.apache.org/repos/asf/mina.git mina
>
> Now, what you get is the *full* MINA repo, and that includes MINA 3.0,
> probably not what you want. Here is what you get when you run this command
> :
>
> $ git tag
> 0.8.3
> 0.8.4
> ...
> 2.0.5
> 2.0.6
> 2.0.7
> 2.0.8
> 2.0.9
> 3.0.0-M1
> 3.0.0-M2
> mina-parent-3.0.0-M1
>
>
> You need to checkout the MINA 2.0.10 tag :
>
> $ git checkout -b 2.0.10 2.0.10
> Switched to a new branch '2.0.10'
>
>
> That will allow you to see the full source used by this tag, and to
> retreive the file you are looking at :
>
> $ find . -name SslFilter.java
> ./mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
>
> I'll update the http://mina.apache.org/mina-project/sources.html page to
> reflect that.
>
> Thanks !
>
>


Re: ProtocolCodecFilter threading model

2015-10-07 Thread Jon V.
Yeah like if you have a blocking database lookup then you would use the
executor filter to allow a bunch of blocking operations to occur without
blocking the entire IoProcessor. The executor filter is not really supposed
to make things faster.
On Oct 7, 2015 3:50 PM, "Марат Гайнуллин"  wrote:

> Hi, Jon!
> Thak you for information about IoProcessors. If there are already
> cores*2 IoProcessors, than things change much. It seems, that executor
> filter is useless at all if a server doesn't perform any waiting/sleeping,
> etc. It seems, that executor filter helps, when there are waiting/sleeping
> in further server logic. Am i right?
> 7 окт. 2015 г. 10:40 PM пользователь "Jon V." 
> написал:
>
> > It would use more memory and since there is already 2x IoProcessors for
> cpu
> > cores there would be no speedup. In fact it would lead to more memory
> > fragmentation/cache misses and require one thread for every session.
> >
> > Basically, it would be a bad idea.
> > On Oct 7, 2015 3:36 PM, "Марат Гайнуллин" 
> wrote:
> >
> > > Dear sirs!
> > > It is completely clear for me, that decoding of a buffer must be
> > linear
> > > and tcp messages fragments must be decoded in a serial manner. My
> > question
> > > is about different thing. Why not to decode SEPARATE sessions' data
> > streams
> > > in parallel?
> > > 7 окт. 2015 г. 10:18 PM пользователь "Jon V." 
> > > написал:
> > >
> > > > You also cannot process a linear buffer simultaneously.  TCP is
> linear
> > > and
> > > > reading the messages must be linear.  After you have a list of
> messages
> > > > then you may execute them in parallel but the line decoding of the
> > buffer
> > > > must be single threaded.  The decoder operates on an inbound buffer
> and
> > > > multi-threading this process will cause the buffers to complete out
> of
> > > > order.  There is also no guarantee that the inbound buffer contains a
> > > > complete message.  In this scenario the tail end of a message could
> be
> > > > processed before the previous part which makes the whole thing
> totally
> > > > broken without locks and locks would just eat more cpu with zero
> gain.
> > > > On Oct 7, 2015 2:53 PM, "Emmanuel Lécharny" 
> > wrote:
> > > >
> > > > > Le 07/10/15 20:44, Марат Гайнуллин a écrit :
> > > > > > Dear sirs!
> > > > > >  I am happy to know, that DIRMINA-1013 has been fixed.
> > > > > > I have a question. I think, that while decoding TCP messages in
> > > > separate
> > > > > > sessions, server SHOULD do it in parallel. Why your last comment
> on
> > > > > > DIRMINA-934 was about not to put executor filter before decoder
> in
> > > TCP?
> > > > > Because doing so will put your server atrisk. Note that you already
> > > have
> > > > > more than one thread processing incoming messages (IoProcessors)
> and
> > > TCP
> > > > > does not guarantee you that a message will be delivered in one
> piece.
> > > > > Now, let's assume you have an exectir *before* the decoder : then
> for
> > > > > one specific session, more than one thread might be used to decode
> a
> > > > > message, which means that potentially, for fragmented messages,
> more
> > > > > than one thread will be in charge of decoding fration of a message.
> > > this
> > > > > simply does not fly...
> > > > >
> > > > > For separate sessions, there is absolutely no problem, because each
> > > > > session might be handled by a different IoProcessor.
> > > > >
> > > > > Performance wise, you might object that while a message is being
> > > > > decoded, then another session could be blocked because the thread
> is
> > > > > busy decoding (as the two sessions are handled by the same
> > IoProcessor
> > > > > thread). that would be true, except that when an IoProcessor thread
> > is
> > > > > busy decoding, it uses 100% of the CPU of the core it run on, so
> > there
> > > > > is no 'room' for some other exacution. So having an executor before
> > the
> > > > > decoder is simply useless, unless you haven't declared as many
> > > > > IoProcessors as you have core on your server.
> > > > >
> > > > > The only case where it's annoying is when your decoder is accessing
> > > > > external resources and has to wait for them : unlikely...
> > > > > Hope it helps !
> > > > >
> > > > >
> > > >
> > >
> >
>


Re: ProtocolCodecFilter threading model

2015-10-07 Thread Jon V.
It would use more memory and since there is already 2x IoProcessors for cpu
cores there would be no speedup. In fact it would lead to more memory
fragmentation/cache misses and require one thread for every session.

Basically, it would be a bad idea.
On Oct 7, 2015 3:36 PM, "Марат Гайнуллин"  wrote:

> Dear sirs!
> It is completely clear for me, that decoding of a buffer must be linear
> and tcp messages fragments must be decoded in a serial manner. My question
> is about different thing. Why not to decode SEPARATE sessions' data streams
> in parallel?
> 7 окт. 2015 г. 10:18 PM пользователь "Jon V." 
> написал:
>
> > You also cannot process a linear buffer simultaneously.  TCP is linear
> and
> > reading the messages must be linear.  After you have a list of messages
> > then you may execute them in parallel but the line decoding of the buffer
> > must be single threaded.  The decoder operates on an inbound buffer and
> > multi-threading this process will cause the buffers to complete out of
> > order.  There is also no guarantee that the inbound buffer contains a
> > complete message.  In this scenario the tail end of a message could be
> > processed before the previous part which makes the whole thing totally
> > broken without locks and locks would just eat more cpu with zero gain.
> > On Oct 7, 2015 2:53 PM, "Emmanuel Lécharny"  wrote:
> >
> > > Le 07/10/15 20:44, Марат Гайнуллин a écrit :
> > > > Dear sirs!
> > > >  I am happy to know, that DIRMINA-1013 has been fixed.
> > > > I have a question. I think, that while decoding TCP messages in
> > separate
> > > > sessions, server SHOULD do it in parallel. Why your last comment on
> > > > DIRMINA-934 was about not to put executor filter before decoder in
> TCP?
> > > Because doing so will put your server atrisk. Note that you already
> have
> > > more than one thread processing incoming messages (IoProcessors) and
> TCP
> > > does not guarantee you that a message will be delivered in one piece.
> > > Now, let's assume you have an exectir *before* the decoder : then for
> > > one specific session, more than one thread might be used to decode a
> > > message, which means that potentially, for fragmented messages, more
> > > than one thread will be in charge of decoding fration of a message.
> this
> > > simply does not fly...
> > >
> > > For separate sessions, there is absolutely no problem, because each
> > > session might be handled by a different IoProcessor.
> > >
> > > Performance wise, you might object that while a message is being
> > > decoded, then another session could be blocked because the thread is
> > > busy decoding (as the two sessions are handled by the same IoProcessor
> > > thread). that would be true, except that when an IoProcessor thread is
> > > busy decoding, it uses 100% of the CPU of the core it run on, so there
> > > is no 'room' for some other exacution. So having an executor before the
> > > decoder is simply useless, unless you haven't declared as many
> > > IoProcessors as you have core on your server.
> > >
> > > The only case where it's annoying is when your decoder is accessing
> > > external resources and has to wait for them : unlikely...
> > > Hope it helps !
> > >
> > >
> >
>


Re: ProtocolCodecFilter threading model

2015-10-07 Thread Jon V.
You also cannot process a linear buffer simultaneously.  TCP is linear and
reading the messages must be linear.  After you have a list of messages
then you may execute them in parallel but the line decoding of the buffer
must be single threaded.  The decoder operates on an inbound buffer and
multi-threading this process will cause the buffers to complete out of
order.  There is also no guarantee that the inbound buffer contains a
complete message.  In this scenario the tail end of a message could be
processed before the previous part which makes the whole thing totally
broken without locks and locks would just eat more cpu with zero gain.
On Oct 7, 2015 2:53 PM, "Emmanuel Lécharny"  wrote:

> Le 07/10/15 20:44, Марат Гайнуллин a écrit :
> > Dear sirs!
> >  I am happy to know, that DIRMINA-1013 has been fixed.
> > I have a question. I think, that while decoding TCP messages in separate
> > sessions, server SHOULD do it in parallel. Why your last comment on
> > DIRMINA-934 was about not to put executor filter before decoder in TCP?
> Because doing so will put your server atrisk. Note that you already have
> more than one thread processing incoming messages (IoProcessors) and TCP
> does not guarantee you that a message will be delivered in one piece.
> Now, let's assume you have an exectir *before* the decoder : then for
> one specific session, more than one thread might be used to decode a
> message, which means that potentially, for fragmented messages, more
> than one thread will be in charge of decoding fration of a message. this
> simply does not fly...
>
> For separate sessions, there is absolutely no problem, because each
> session might be handled by a different IoProcessor.
>
> Performance wise, you might object that while a message is being
> decoded, then another session could be blocked because the thread is
> busy decoding (as the two sessions are handled by the same IoProcessor
> thread). that would be true, except that when an IoProcessor thread is
> busy decoding, it uses 100% of the CPU of the core it run on, so there
> is no 'room' for some other exacution. So having an executor before the
> decoder is simply useless, unless you haven't declared as many
> IoProcessors as you have core on your server.
>
> The only case where it's annoying is when your decoder is accessing
> external resources and has to wait for them : unlikely...
> Hope it helps !
>
>


Re: Memory leak

2015-09-01 Thread Jon V.
Emmanuel is correct. You have to manage that backlog. Mina provides write
request handlers so you get notifications when the data is written. If you
detect that data isn't writing you should take steps to mitigate sending
data to that session.
On Sep 1, 2015 12:01 PM, "Emmanuel Lécharny"  wrote:

> Le 01/09/15 17:26, Leonardo D'Alimonte a écrit :
> > Hello Emmanuel,
> > actually it seems as if the Queue data structure continues to
> > increase..message after message.
> > We cannot check if the our device receive the message, the implemented
> > protocol doesn't allow this, do you mean checking if the session goes in
> an
> > IDLE state? I can add override of method "sessionIdle(IoSession,
> > IdleStatus) to our HandlerAdapter..
>
> If the remote device brutally disconnected from the server, you will
> *not* be able to know about it. That means you will keep sending data to
> this inexistant client, and as this client is not there to read those
> messages, they will just accumulate in memory.
>
> You have to manage the idle state of your sessions : after a delay, you
> might want to kill the session, which will remove all the pending messages.
>
> Another option : when you send a message to a client, you know it has
> been actually sent when you receive the messageSent event. If you don't
> get this event, that means your client is not reading the messages. A
> smart way to mitigate what we call 'slow readers' is to check that each
> message written into a session has been sent and if not, kill the
> session (or kill it after a number of written messages for which you
> havent received a messageSent event).
>
>


Re: EOFException when file gets modified during sendFile

2015-05-15 Thread Jon V.
Maybe the file should be locked until send is complete.  Really shouldn't
allow sending of a file while it is being modified.
On May 15, 2015 5:31 PM, "Charlie Kim" 
wrote:

> Hi there, I'm seeing EOFException when file gets modified during sendFile
> command.
> Here is the scenario.  Client receives the size of the file as 1000.
> Then, before inputstream is read, file gets modified which the file size
> becomes greater that what it was specified and this causes read to fail.
>
> debug2: exec request accepted on channel 0
> Sink: C0644 1000 foo.txt
>
> debug2: channel 0: read<=0 rfd 5 len 0
> debug2: channel 0: read failed
> debug2: channel 0: close_read
> debug2: channel 0: input open -> drain
> debug2: channel 0: ibuf empty
>
> here is the code that writes the length.
>
> https://github.com/apache/mina-sshd/blob/master/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java#L505
> Could we use available() method of an InputStream and use that instead
> when writing C0644 1000 foo.txt?I've tried this workaround and seems to
> work for me.
> Thanks
>
>


Re: MINA as a WEB Service

2015-05-13 Thread Jon V.
Mina is a networking framework for building web services.  It is not a web
service itself.
On May 13, 2015 5:50 AM, "Jochen Seliger" 
wrote:

> Hi,
> I need a functionality to let qasi any mashine, running our
> client-programm, to
> connect to a central instance.
> Therefor the HTTP Update header procedure seems to be the proper way.
> As we need to allow the named client-programms to retieve and access an
> data
> base connection and RMI-Registries on both sides, an SSH seems to be next
> step.
> At the Apache-MINA site I did not find information, how to run MINA as an
> WEB
> service.
> Could anybody provide me some information?
>
> Regards
> Jochen Seliger
>


Re: How to debug ghost sessions

2015-05-11 Thread Jon V.
Ghost sessions are a result of a broken TCP connection.  It is possible
that the client lost internet connection and was unable to correctly
terminate the TCP session.  Therefore, your application will never get a
TCP close until the default idleness timer invokes or you use Mina's
internal idleness to close sessions.

On Mon, May 11, 2015 at 2:33 AM, 白玉雄  wrote:

> Hi,
> I print all attributes of a bug session as follow,  Mina processes the
> last request at 2015-05-11 01:58:34, then stucked and no request is
> processed afterwards.
>
>
> namevalue
> getWrittenBytesThroughput0.0
> getLastIoTime2015-05-11 02:23:11
> getReadBytes5971
> getReadBytesThroughput0.0
> isConnectedtrue
> getLastWriterIdleTime2015-05-11 01:58:34
> isWriterIdlefalse
> getReaderIdleCount0
> getLocalAddress/xx.xx.xx.xx:
> getWriterIdleCount0
> getWrittenMessagesThroughput0.0
> ID3233
> getServiceAddress/0.0.0.0:x
> getReadMessages30
> getLastReadTime2015-05-11 02:08:48
> isSecuredfalse
> isReaderIdlefalse
> getLastReaderIdleTime2015-05-11 01:58:34
> getWrittenBytes2221
> getRemoteAddress/xx.xx.xx.xx:x
> getReadMessagesThroughput0.0
> isBothIdlefalse
> isReadSuspendedfalse
> getScheduledWriteMessages-39
> getLastWriteTime2015-05-11 02:23:11
> getCreationTime2015-05-11 01:58:34
> getBothIdleCount0
> getLastBothIdleTime2015-05-11 01:58:34
> isWriteSuspendedfalse
> isClosingfalse
> getWrittenMessages39
>
> -- Original --
> From:  "白玉雄";
> Date:  Wed, May 6, 2015 02:47 PM
> To:  "users";
>
> Subject:  Re: How to debug ghost sessions
>
>
> I am sure that idle event is fired. After no heartbeat for 900 seconds ,
> session was closed by server.
>
> -- Original --
> From:  "Emmanuel Lécharny";
> Date:  Wed, May 6, 2015 02:31 PM
> To:  "users";
>
> Subject:  Re: How to debug ghost sessions
>
>
> Le 06/05/15 05:24, 白玉雄 a écrit :
> > Hi all,
> > My mina server neither process session request nor disconnect the
> session as idle. and this happens only on few of sessions, most of them
> works well.
> >
> >
> > Some Code:
> > public void run(int port) throws IOException {
> >   this.acceptor = new NioSocketAcceptor();
> >   this.acceptor.setReuseAddress(true);
> >
> >
> >   this.acceptor.getFilterChain().addLast("codec",new
> ProtocolCodecFilter(new ClwMessageProtocolCodecFactory()));
> >
> >
> >   this.acceptor.getFilterChain().addLast("logger", new
> LoggingFilter());
> >   this.acceptor.getFilterChain().addLast("threadPool", new
> ExecutorFilter(new
> UnorderedThreadPoolExecutor(PropertiesHander.getInt("MAXIMUM_POOL_SIZE",
> 16;
> >
> >
> >   this.acceptor.getSessionConfig().setReadBufferSize(512);
> >   this.acceptor.getSessionConfig().setReceiveBufferSize(512);
> >   // set idle time, default 900 seconds
> >
>  
> this.acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE,PropertiesHander.getInt("SESSION_IDLE_TIME",900));
> >   this.acceptor.setHandler(ioHandler);
> >   this.acceptor.bind(new InetSocketAddress(port));
> >   LOGGER.info("Socket server Listening on port "+
> PropertiesHander.getInt("SERVER_PORT", port));
> >   }
> >
> >
> >
> > Some phenomenons:
> > 1、The ghost session can be found by
> this.acceptor.getManagedSessions().get(sessionId)
> > 2、If force the client disconnect from server and reconnect again, the
> client now works well and request was processed normally.
> >
> > It seems that the session was stucked.
> >
> >
> > Question:
> > Why this happens
> No idea... You aren't providing enough information to know what's going on.
>
> > and How to reappear and debug this?
> Setting the idle time is good, but at some point you must check the
> event that is fired when teh session has been idle for 900 seconds. Are
> you doing that ?
>


Re: How to Detect Wired Network Disconnect in Apache Mina

2015-04-17 Thread Jon V.
I forget how Mina handles it but SocketChannel write and read both generate
exceptions to alert of disconnect.

Mina may abstract that somehow.
On Apr 17, 2015 8:38 AM, "Nikunj Patel"  wrote:

> Is there any way where session.write() can generate any exception and base
> on that we can take decision.
>
> On Fri, Apr 17, 2015 at 6:00 PM, Jon V.  wrote:
>
> > Write and read is only the real way to detect disconnect.  Sockets can be
> > valid and live on after a disconnect and reconnect.
> >
> > When a network cable is removed, you may get a disconnect after the OS
> > internal timeout. Otherwise you have to rely on your own idleness timer.
> > On Apr 17, 2015 6:28 AM, "Nikunj Patel"  wrote:
> >
> > > Dear Sir,
> > >
> > > I have develop MINA Client which is connected to remote server. I am
> > trying
> > > to detect Wired Network Disconnect in that but it is not identify it.
> > Also
> > > session.write is not generating any exception. Before submit if i check
> > > with session.isConnected then also it return true.
> > >
> > > Can any one help me how I can detect such network disconnection in
> Apache
> > > Mina.
> > >
> > > --
> > > Regards,
> > > Nikunj Patel.
> > >
> >
>
>
>
> --
> Regards,
> Nikunj Patel.
>


Re: How to Detect Wired Network Disconnect in Apache Mina

2015-04-17 Thread Jon V.
Write and read is only the real way to detect disconnect.  Sockets can be
valid and live on after a disconnect and reconnect.

When a network cable is removed, you may get a disconnect after the OS
internal timeout. Otherwise you have to rely on your own idleness timer.
On Apr 17, 2015 6:28 AM, "Nikunj Patel"  wrote:

> Dear Sir,
>
> I have develop MINA Client which is connected to remote server. I am trying
> to detect Wired Network Disconnect in that but it is not identify it. Also
> session.write is not generating any exception. Before submit if i check
> with session.isConnected then also it return true.
>
> Can any one help me how I can detect such network disconnection in Apache
> Mina.
>
> --
> Regards,
> Nikunj Patel.
>


Re: Virtual IP Load Balancer

2015-03-25 Thread Jon V.
Should have said Stack Exchange. Meant it in a generic sense.
On Mar 25, 2015 9:18 AM, "John Hartnup"  wrote:

> Neither is Stack Overflow the place to discuss it. http://serverfault.com/
> or maybe http://superuser.com/ might be OK. I think my suggestion of
> haproxy will do the job.
>
> On Wed, Mar 25, 2015 at 1:06 PM Jon V.  wrote:
>
> > This is not the correct place to discuss this.  Maybe try stack overflow.
> >
> > On Wed, Mar 25, 2015 at 4:59 AM, rkreddy.bogati <
> rkreddy.bog...@gmail.com>
> > wrote:
> >
> > > @Ukslim,  Thanks for your response.
> > >
> > > Let me explain the details requirement.
> > >
> > > I have one IP Address (that is not connected to any physical machine),
> > > which
> > > will receive the request.
> > > As soon as request receives it should delegate that request to the
> given
> > IP
> > > Addresses (those are attached to any Physical machine) by Round-robin
> > > algorithm.
> > >
> > > To achieve this I would like to use Open source tool which suites my
> > > requirement.
> > >
> > > Note:- This requirement for Web-Application developed on JAVA/J2EE
> > > platform.
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > > http://apache-mina.10907.n7.nabble.com/Virtual-IP-Load-
> > Balancer-tp46678p46698.html
> > > Sent from the Apache MINA User Forum mailing list archive at
> Nabble.com.
> > >
> >
>


Re: Virtual IP Load Balancer

2015-03-25 Thread Jon V.
This is not the correct place to discuss this.  Maybe try stack overflow.

On Wed, Mar 25, 2015 at 4:59 AM, rkreddy.bogati 
wrote:

> @Ukslim,  Thanks for your response.
>
> Let me explain the details requirement.
>
> I have one IP Address (that is not connected to any physical machine),
> which
> will receive the request.
> As soon as request receives it should delegate that request to the given IP
> Addresses (those are attached to any Physical machine) by Round-robin
> algorithm.
>
> To achieve this I would like to use Open source tool which suites my
> requirement.
>
> Note:- This requirement for Web-Application developed on JAVA/J2EE
> platform.
>
>
>
> --
> View this message in context:
> http://apache-mina.10907.n7.nabble.com/Virtual-IP-Load-Balancer-tp46678p46698.html
> Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
>


Re: question

2015-03-24 Thread Jon V.
This isn't necessarily something that would be the responsibility of Mina.
Just as you developed your own game server, you will have to add any kind
of clustering features yourself.
On Mar 24, 2015 11:16 AM, "antares"  wrote:

> Hi Folks,
>
> i created a game server and i would like to have a suggestion about to
> sharing sessions between other game server instances.
> In other words something about clusterizing
> is that possible ?
>
> Thanks
> Francesco
>


Re: Mina server not responsive

2015-03-22 Thread Jon V.
Glad you figured it out.
On Mar 22, 2015 6:39 PM, "Jianbao (Jim) Tao"  wrote:

> Thank you, Jon and Emmanuel. I tried adding a logging filter and all. I
> finally found the root cause by taking a thread dump. It was due to a
> deadlock in our business logic code.
>
> I tried upgrading Mina version. However, I ran into a roadblock where Mina
> seemed somehow not receiving new data after the first chunk. It wasn't a
> priority to upgrade Mina at the time so I stopped investigating further.
> Maybe I will bring this here in the future.
>
> Best regards,
> Jim
>
> On Sat, Mar 21, 2015 at 5:10 PM, Emmanuel Lécharny 
> wrote:
>
> > Le 21/03/15 20:01, Jianbao (Jim) Tao a écrit :
> > > Hi,
> > >
> > > I am facing a issue as follows.
> > >
> > > We have a proxy server developed with Mina. Recently after some changes
> > in
> > > the business logic that hardly seem relevant, the server starts to
> show a
> > > random behavior frequently, in which it will simply not respond to any
> > > request. I used curl to manually verify. It appears that the sever is
> > able
> > > to accept connection, but it doesn't seem to accept any data as I
> cannot
> > > see any logs on the server side.
> > >
> > > The version we are using is mina-core 2.0.0-M6.
> > >
> > > Right now I am running out of ideas to debug this issue. So, can anyone
> > > offer some advice about what I can try to investigate this issue? If
> you
> > > need more details to understand the issue, please, please let me know.
> I
> > > will do my best to provide them.
> >
> > I'll suggest you switch first to the latest MINA version (2.0.9).
> >
> > Regarding your issue, we can't tell anything with the provided infos.
> > What I would suggest is that you add a Logger filter to see if the
> > server is actually receiving the messages.
> >
>


Re: Session Sharing between applications

2015-03-21 Thread Jon V.
I am going to take a little leap and say that Java is probably not the best
to develop a proxy application.  Mina's design is also more optimized for
request response type situations and may introduce some unnecessary latency
into the proxy.

Otherwise, it is just as Emmanuel said. You write all the received data
into the other IoSession.
On Mar 21, 2015 8:15 PM, "Emmanuel Lécharny"  wrote:

> Le 21/03/15 17:33, Nikunj Patel a écrit :
> > Dear All,
> >
> > I am going to develop network application using apache mina where
> > application continually connected to remote server and also open port for
> > client connection. When any client send message it will pass to remote
> > server and response received from remote server it will pass to
> respective
> > client which request has sent. My TCP Server must keep live connection
> with
> > remote tcp server.
> >
> > architecture would be like
> >
> > TCP Client1 <--> TCP Server <--> Remote TCP Server
> > TCP Client2
> > .
> > .
> > TCP Clientn
> >
> > I have no idea how I can response back to tcp client when response
> received
> > from remote tcp server.
> >
> > Please find attached my sample application for your reference and guide
> me
> > how can I achieve it.
> >
> The attachement didn't make it.
>
> Regardless, you are just writing a proxy server. I suppose that your
> proxy send a request to the remote server when it receives a message
> from your client, so sending back a response to this client when your
> server receives the response from the remote server is as simple as
> writing the response into the client session.
>


Re: Mina server not responsive

2015-03-21 Thread Jon V.
We are going to need a lot more.  I would first use visual VM and figure if
any threads are running 100% and grab stack traces.
On Mar 21, 2015 3:03 PM, "Jianbao (Jim) Tao"  wrote:

> Hi,
>
> I am facing a issue as follows.
>
> We have a proxy server developed with Mina. Recently after some changes in
> the business logic that hardly seem relevant, the server starts to show a
> random behavior frequently, in which it will simply not respond to any
> request. I used curl to manually verify. It appears that the sever is able
> to accept connection, but it doesn't seem to accept any data as I cannot
> see any logs on the server side.
>
> The version we are using is mina-core 2.0.0-M6.
>
> Right now I am running out of ideas to debug this issue. So, can anyone
> offer some advice about what I can try to investigate this issue? If you
> need more details to understand the issue, please, please let me know. I
> will do my best to provide them.
>
> Many thanks.
>
> Best regards,
> Jim
>


Re: Problem with closing sessions after exception

2015-02-09 Thread Jon V.
How are you interrupting during SSL handshake?
On Feb 9, 2015 4:04 AM, "Ing. Jan Kaláb"  wrote:

> The version is 2.0.9.
>
> I can't provide you the whole code, only what's in the question on
> StackOverflow, but the JMeter plan is attached. Maybe if you ask more
> precisly about part of the code you are interested in, I can give you
> that.
>
> I am pretty sure the session is not closed. The file descriptors for
> sockets are still there, and the server stops responding after a while
> (too many open files). But I found out it happens only when the
> connection is interrupted during the SSL handshake phase. If I
> interrupt the connection later (or sooner), the session is closed
> properly. If I fail the handshake for other reasons (bad cipher), it's
> also closed properly.
>
> So maybe I should file a bug for this?
>
> 2015-02-07 1:53 GMT+01:00 Emmanuel Lécharny :
> > Le 06/02/15 14:05, Ing. Jan Kaláb a écrit :
> >> Hi,
> >> can someone please help me with this problem:
> >> https://stackoverflow.com/q/28366323
> >>
> >> Thanks!
> > First of all, which MINA version are you using ?
> >
> > Also can you provide the code that you use, and the Jmeter plan ?
> >
> > FTR, calling session.close(true) does not close the session immediatly,
> > it just close the session regardless the waiting pending writes. What
> > happens is that the session is scheduled to be closed, and the
> > sessionClosed event is fired. As it's going to be done in two different
> > thread, it's perfectly possible that the thread handling the
> > sessionClosed() event might not be associated with any listener, as the
> > addListener() call might be executed after the session has been fully
> > closed.
> >
> > Thanks !
> >
>


Re: Is IoSession.write() thread-safe in mina trunk branch?

2014-08-16 Thread Jon V.
It may be a flaw in the redesign. The trunk is an entire redesign of Mina.
On Aug 16, 2014 4:04 PM, "Kai ZHANG"  wrote:

> If the write() should be synchronized by myself, why the API documentation
> says this class is thread safe?
>
> I added my application details and the explanations in another email.
> Please tell me what is the correct usage of IoSession.write(). Whether the
> new implementation is a bug or new design.
>
> Thanks.
>
> On 08/17/2014 02:45 AM, Jens Reimann wrote:
>
>> Yes, but the call to write() can originate from any thread and thus is
>> not thread safe. All handlers in the write call get called unsynchronized.
>> This also causes issues at other locations like the gzip filter.
>>
>> There are two options, synchronize write calls yourself by surrounding
>> calls to write() with a mutex lock or semaphore.
>>
>> Or, if you cannot synchronize all write calls (e.g. when you use the
>> Heartbeat filter, which calls write on its own) you need to use the
>> ExecutorFilter (I think that was the name). This can be used to force read
>> and write calls to a specific thread.
>>
>> Jens
>>
>> On Aug 16, 2014 8:18 PM, Emmanuel Lecharny  wrote:
>>
>>>  From the top of my head (I'm in a bus atm), each session has its own
>>> chain
>>> of filter, thus its own instance. The variable is not shared, and the
>>> session is always handled by the same IoPricessor, so the same thread.
>>> That
>>> should be thread safe unless you start doing weird things with an
>>> executor.
>>> Le 16 août 2014 18:06, "Kai ZHANG"  a écrit :
>>>
>>>  Hi,

 I am a beginer of Mina. I read the api doc located at:

 /http://mina.apache.org/mina-project/apidocs/org/apache/
 mina/core/session/IoSession.html/

 It says that IoSession is thread-safe.

 But when I read the source of mina trunk branch. I found the
 IoSession.write() method may be not thread-safe. The java source file
 is :

 /./core/src/main/java/org/apache/mina/session/AbstractIoSession.java/

 Here is the method calling chain:
 AbstractIoSession.write()
 -> AbstractIoSession.doWriteWithFuture
 -> AbstractIoSession.processMessageWriting()
 -> AbstractIoFilter.messageWriting()
 -> AbstractIoSession.callWriteNextFilter()

 The code which is thread-safe reside in AbstractIoSession.
 callWriteNextFilter(),
 here is the code:

  /**
* process session message received event using the filter
  chain. To be called by the session {@link SelectorLoop} .
*
* @param message the received message
*/
   @Override
   public void callWriteNextFilter(WriteRequest message) {
   if (IS_DEBUG) {
   LOG.debug("calling next filter for writing for message
  '{}' position : {}", message, writeChainPosition);
   }

  /writeChainPosition--;/

   if (writeChainPosition < 0 || chain.length == 0) {
   // end of chain processing
   enqueueWriteRequest(message);
   } else {
   chain[writeChainPosition].messageWriting(this,
 message,
  this);
   }

  /writeChainPosition++;/
   }

 Here the variable "writeChainPosition" is not thread-safe, If more than
 one thread call IoSession.write() concurrently, the "writeChainPosition"
 may have race condition.

 The result is some of the IoFilter may be skipped or called twice, and
 the
 message data passed down the filter chain may be broken.

 Could you tell me if my understanding is correct?

 Is IoSession.write() method designed to be thread-safe or should I use a
 lock for every concurrent IoSession.write() operation?






>


Re: Is IoSession.write() thread-safe in mina trunk branch?

2014-08-16 Thread Jon V.
OK so this is new. I pulled the source. The tracking of the filter position
on the IoSession is the problem. I don't remember the old style filter
chain having that problem.  However the old style wasn't as efficient.  If
the write chain did occur in the selector loop then it wouldn't be a
problem. Either that or redesign the filter chain flow to fix this problem.
On Aug 16, 2014 3:24 PM, "Kai ZHANG"  wrote:

> But before the message added into writeQueue, it will be pass down through
> the filter chain.
> The filter operation is runned in the calling thread.
>
>  If two thread call write() on the same time, then the target IoSession's
> filter chain will be iterated in two threads simultaneously.  But the
> IoSession has a 'writeChainPosition' variable to store the offset of next
> filter to run, which may be modified by two threads without any
> synchronization mechanism.
>
> On 08/17/2014 02:59 AM, Jon V. wrote:
>
>> It is my understanding that the write is occurring on the the selector
>> loop. This occurs on the same selector loop every time and therefore is
>> thread-safe. When you call write the params are encapsulated and triggered
>> for execution on the select loop. It does not occur in the same stack as
>> the caller of write()
>> On Aug 16, 2014 2:45 PM, "Jens Reimann"  wrote:
>>
>>  Yes, but the call to write() can originate from any thread and thus is
>>> not
>>> thread safe. All handlers in the write call get called unsynchronized.
>>> This
>>> also causes issues at other locations like the gzip filter.
>>>
>>> There are two options, synchronize write calls yourself by surrounding
>>> calls to write() with a mutex lock or semaphore.
>>>
>>> Or, if you cannot synchronize all write calls (e.g. when you use the
>>> Heartbeat filter, which calls write on its own) you need to use the
>>> ExecutorFilter (I think that was the name). This can be used to force
>>> read
>>> and write calls to a specific thread.
>>>
>>> Jens
>>>
>>> On Aug 16, 2014 8:18 PM, Emmanuel Lecharny  wrote:
>>>
>>>>  From the top of my head (I'm in a bus atm), each session has its own
>>>>
>>> chain
>>>
>>>> of filter, thus its own instance. The variable is not shared, and the
>>>> session is always handled by the same IoPricessor, so the same thread.
>>>>
>>> That
>>>
>>>> should be thread safe unless you start doing weird things with an
>>>>
>>> executor.
>>>
>>>> Le 16 août 2014 18:06, "Kai ZHANG"  a écrit :
>>>>
>>>>  Hi,
>>>>>
>>>>> I am a beginer of Mina. I read the api doc located at:
>>>>>
>>>>> /http://mina.apache.org/mina-project/apidocs/org/apache/
>>>>> mina/core/session/IoSession.html/
>>>>>
>>>>> It says that IoSession is thread-safe.
>>>>>
>>>>> But when I read the source of mina trunk branch. I found the
>>>>> IoSession.write() method may be not thread-safe. The java source file
>>>>>
>>>> is :
>>>
>>>> /./core/src/main/java/org/apache/mina/session/AbstractIoSession.java/
>>>>>
>>>>> Here is the method calling chain:
>>>>> AbstractIoSession.write()
>>>>> -> AbstractIoSession.doWriteWithFuture
>>>>> -> AbstractIoSession.processMessageWriting()
>>>>> -> AbstractIoFilter.messageWriting()
>>>>> -> AbstractIoSession.callWriteNextFilter()
>>>>>
>>>>> The code which is thread-safe reside in
>>>>>
>>>> AbstractIoSession.callWriteNextFilter(),
>>>
>>>> here is the code:
>>>>>
>>>>> /**
>>>>>   * process session message received event using the filter
>>>>> chain. To be called by the session {@link SelectorLoop} .
>>>>>   *
>>>>>   * @param message the received message
>>>>>   */
>>>>>  @Override
>>>>>  public void callWriteNextFilter(WriteRequest message) {
>>>>>  if (IS_DEBUG) {
>>>>>  LOG.debug("calling next filter for writing for message
>>>>> '{}' position : {}", message, writeChainPosition);
>>>>>  }
>>>>>
>>>>> /writeChainPosition--;/
>>>>>
>>>>>  if (writeChainPosition < 0 || chain.length == 0) {
>>>>>  // end of chain processing
>>>>>  enqueueWriteRequest(message);
>>>>>  } else {
>>>>>  chain[writeChainPosition].messageWriting(this,
>>>>> message,
>>>>> this);
>>>>>  }
>>>>>
>>>>> /writeChainPosition++;/
>>>>>  }
>>>>>
>>>>> Here the variable "writeChainPosition" is not thread-safe, If more than
>>>>> one thread call IoSession.write() concurrently, the
>>>>>
>>>> "writeChainPosition"
>>>
>>>> may have race condition.
>>>>>
>>>>> The result is some of the IoFilter may be skipped or called twice, and
>>>>>
>>>> the
>>>
>>>> message data passed down the filter chain may be broken.
>>>>>
>>>>> Could you tell me if my understanding is correct?
>>>>>
>>>>> Is IoSession.write() method designed to be thread-safe or should I use
>>>>>
>>>> a
>>>
>>>> lock for every concurrent IoSession.write() operation?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>


Re: Is IoSession.write() thread-safe in mina trunk branch?

2014-08-16 Thread Jon V.
It is my understanding that the write is occurring on the the selector
loop. This occurs on the same selector loop every time and therefore is
thread-safe. When you call write the params are encapsulated and triggered
for execution on the select loop. It does not occur in the same stack as
the caller of write()
On Aug 16, 2014 2:45 PM, "Jens Reimann"  wrote:

> Yes, but the call to write() can originate from any thread and thus is not
> thread safe. All handlers in the write call get called unsynchronized. This
> also causes issues at other locations like the gzip filter.
>
> There are two options, synchronize write calls yourself by surrounding
> calls to write() with a mutex lock or semaphore.
>
> Or, if you cannot synchronize all write calls (e.g. when you use the
> Heartbeat filter, which calls write on its own) you need to use the
> ExecutorFilter (I think that was the name). This can be used to force read
> and write calls to a specific thread.
>
> Jens
>
> On Aug 16, 2014 8:18 PM, Emmanuel Lecharny  wrote:
> >
> > From the top of my head (I'm in a bus atm), each session has its own
> chain
> > of filter, thus its own instance. The variable is not shared, and the
> > session is always handled by the same IoPricessor, so the same thread.
> That
> > should be thread safe unless you start doing weird things with an
> executor.
> > Le 16 août 2014 18:06, "Kai ZHANG"  a écrit :
> >
> > > Hi,
> > >
> > > I am a beginer of Mina. I read the api doc located at:
> > >
> > > /http://mina.apache.org/mina-project/apidocs/org/apache/
> > > mina/core/session/IoSession.html/
> > >
> > > It says that IoSession is thread-safe.
> > >
> > > But when I read the source of mina trunk branch. I found the
> > > IoSession.write() method may be not thread-safe. The java source file
> is :
> > >
> > > /./core/src/main/java/org/apache/mina/session/AbstractIoSession.java/
> > >
> > > Here is the method calling chain:
> > > AbstractIoSession.write()
> > > -> AbstractIoSession.doWriteWithFuture
> > > -> AbstractIoSession.processMessageWriting()
> > > -> AbstractIoFilter.messageWriting()
> > > -> AbstractIoSession.callWriteNextFilter()
> > >
> > > The code which is thread-safe reside in
> AbstractIoSession.callWriteNextFilter(),
> > > here is the code:
> > >
> > >/**
> > >  * process session message received event using the filter
> > >chain. To be called by the session {@link SelectorLoop} .
> > >  *
> > >  * @param message the received message
> > >  */
> > > @Override
> > > public void callWriteNextFilter(WriteRequest message) {
> > > if (IS_DEBUG) {
> > > LOG.debug("calling next filter for writing for message
> > >'{}' position : {}", message, writeChainPosition);
> > > }
> > >
> > >/writeChainPosition--;/
> > >
> > > if (writeChainPosition < 0 || chain.length == 0) {
> > > // end of chain processing
> > > enqueueWriteRequest(message);
> > > } else {
> > > chain[writeChainPosition].messageWriting(this, message,
> > >this);
> > > }
> > >
> > >/writeChainPosition++;/
> > > }
> > >
> > > Here the variable "writeChainPosition" is not thread-safe, If more than
> > > one thread call IoSession.write() concurrently, the
> "writeChainPosition"
> > > may have race condition.
> > >
> > > The result is some of the IoFilter may be skipped or called twice, and
> the
> > > message data passed down the filter chain may be broken.
> > >
> > > Could you tell me if my understanding is correct?
> > >
> > > Is IoSession.write() method designed to be thread-safe or should I use
> a
> > > lock for every concurrent IoSession.write() operation?
> > >
> > >
> > >
> > >
> > >
>


Re: Performance issue - NioSocketAcceptor

2014-08-15 Thread Jon V.
I also doubt that is the source of the contention.

How expensive the selection queue depends on the OS and chosen selector.
The Windows selector is probably the most expensive. Socket writes are 3x
more costly there than on Ubuntu.
On Aug 15, 2014 5:28 PM, "Emmanuel Lécharny"  wrote:

> Le 15/08/14 16:06, Jon V. a écrit :
> > If you receive 5 bytes then Mina will trigger through the schedule
> > mechanism which means it gets queued and a thread wakes up to process
> that.
> > That wakeup is one of the most expensive parts of the process. How often
> > Mina wakes up is defined by how the producer is writing data to the
> > socket.
>
> In fact, the real problem is the processing of the Selector queue. The
> smaller the data received, the more often Java has to go through an
> expensive processing of a queue of events. Basically, this queue (and
> there are more than one in fact) is synchronized, so there is obviously
> some kind of contention that occurs. I won't go into details here,
> enough said that the selection process is well described in the NIO book
> from Ron Hitchens (http://shop.oreilly.com/product/9780596002886.do)
>
> But here, I'm not sure the problem lies in the processing fo small
> chunks of data.
>
> >
> > As for the parsers it is much more simple and cost effective to buffer
> the
> > XML before processing it.
> Sadly, this is not that simple... Typically, how do you know that you
> are at the end of a XML block ? The only way is to actually parse the
> full XML, and this is why having an stateful event drive parser can
> help, as you just parse the content as it comes, stop when it stops and
> resume when more bytes are arriving.
>
>


Re: Performance issue - NioSocketAcceptor

2014-08-15 Thread Jon V.
If you receive 5 bytes then Mina will trigger through the schedule
mechanism which means it gets queued and a thread wakes up to process that.
That wakeup is one of the most expensive parts of the process. How often
Mina wakes up is defined by how the producer is writing data to the
socket.

As for the parsers it is much more simple and cost effective to buffer the
XML before processing it.
On Aug 15, 2014 3:29 AM, "Emmanuel Lécharny"  wrote:

> Le 15/08/14 08:15, Jon V. a écrit :
> > Yes, if the iohandle is blocking the execution then that would obviously
> do
> > it   That said I am not sure how the reactor threading in Mina would
> handle
> > very small messages sent in a way that prevents the data from
> aggregating.
> > Difference is 20k individual triggers or 1k triggers for the same number
> of
> > messages.
>
> That would nbot even be a problem for MINA : the small pieces of
> messages will just stay in memory until we can produce a message to push
> to the IoHandler. As soon as the bit read from teh socket has been
> processed, the thread is freed.
>
>


Re: Performance issue - NioSocketAcceptor

2014-08-14 Thread Jon V.
Yes, if the iohandle is blocking the execution then that would obviously do
it   That said I am not sure how the reactor threading in Mina would handle
very small messages sent in a way that prevents the data from aggregating.
Difference is 20k individual triggers or 1k triggers for the same number of
messages.
On Aug 15, 2014 2:00 AM, "Emmanuel Lécharny"  wrote:

> Le 15/08/14 05:41, Jon V. a écrit :
> > Emmanuel, is there a line test tool for Mina? I ask because seems like
> the
> > Jedi Jin here has a throughput problem.
>
> Something like
>
> http://blog.softlayer.com/2011/using-iperf-to-troubleshoot-speedthroughput-issues
> should do the trick. But here, with the client and the server o the same
> machine, I doubt the network could be the probelm.
> >
> > Jin,
> > Have you tried benchmarking your code directly?  In all reality I process
> > 30k sockets and 500mb/s using raw TCP in java so if there is a problem it
> > is either your code or Mina.
>
> It's crystal clear that it's not a MINA problem per se. I'm able to
> saturate a 10Mb/s network with more than 20 000 messages per second on
> my computer on my LDAP server using MINA.
>
> One of the possible reasons : the server IoHandler is doing weird things
> (like waiting for an external resource before releasing the thread).
> Typical use case : sendinhg the received data to a remote data base.
>
> So bottom line : what do you do on the server side with the data you
> receive ?
>
>


Re: Performance issue - NioSocketAcceptor

2014-08-14 Thread Jon V.
Emmanuel, is there a line test tool for Mina? I ask because seems like the
Jedi Jin here has a throughput problem.

Jin,
Have you tried benchmarking your code directly?  In all reality I process
30k sockets and 500mb/s using raw TCP in java so if there is a problem it
is either your code or Mina.
Hi there,

I am using Apache Mina to develop a TCP server that handles incoming XML
messages. There is around 60 to 80 concurrent messages sending to TCP
server per minute. If the messages below 60 the TCP server is working fine
and there is no delay receiving the request but problem arises when more
than 60.

 The problem is the messages didn't reach/receive on time. From the log
file I can see the messages are "accumulated" some where and after a while
(between 10 to 30 seconds) all accumulated messages release to TCP server.
Messages reach server on time is very critical in my application.

I try to fine tune the NioSocketAcceptor number of thread, increase read
buffer size, increase io buffer size but all do not help.

I executed a stress test on my local machine using Jmeter with same
throughput and the result is still negative. When NioSocketAcceptor starts
"accumulating" messages I can see Jmeter is throwing:
jmeter.protocol.tcp.sampler.TCPSampler:  java.net.SocketException: Software
caused connection abort: socket write error.
To me this look like NioSocketAcceptor is blocking the messages. After a
while it back to normal again.

Please take note the JMeter and TCP Server are running on the same machine
 - this is to isolate network factor when doing testing. From the result,
seem like it is not something related to network so now I am just focus on
fine tuning the NioSocketAcceptor.

Below is my codes. I will be grateful if anyone can tell me what is going
on internally. I have been stuck in this problem for few months but still
can't find any solution.

IoAcceptor acceptor = new NioSocketAcceptor();

 // Handle the incoming XML message
 PMMessageHandler pmMessageHandler = new PMMessageHandler();

// Initialise Spring configuration
PMUtils pmUtils = PMUtils.getInstance();

pmMessageHandler.setDataProcessor((DataProcessor)pmUtils.getBean("dataProcessor"));

//pmMessageHandler.setPmManager((PMManager)pmUtils.getBean("pmManager"));
acceptor.setHandler(  pmMessageHandler );

// Set the filter chain for log and translate incoming message to char
 acceptor.getFilterChain().addLast( "logger", new
LoggingFilter() );
TextLineCodecFactory textLineCodecFactory = new
TextLineCodecFactory(Charset.forName( "UTF-8" ));

textLineCodecFactory.setDecoderMaxLineLength(PMServer.maxLineLength);
acceptor.getFilterChain().addLast( "codec", new
ProtocolCodecFilter( textLineCodecFactory ));

// Configure buffer size
IoBuffer buffer = IoBuffer.allocate(5120, false);
buffer.setAutoExpand(true);



try {

 // Configure a port for TCP listener
acceptor.bind( new InetSocketAddress(PMServer.port));

Thanks,
KJ


Re: Help with so many concurrent connections

2014-07-15 Thread Jon V.
This isn't really a Mina question.

Seems like you need to work on some tests to find out what parts are the
bottleneck.  I don't know why a buffer would mean faster inserts. Buffers
are good to offload the tasks to other threads and that has its own
performance advantages depending on how your database driver works.
On Jul 15, 2014 5:11 PM, "Eray Yuksek" 
wrote:

> Hi,
>
> I am new in the list so I am not sure if I am sending my question to the
> right list since I know that there is another list called
> d...@mina.apache.org.
> I apologize in advance if this is not the right list and in that case,
> please let me know.
>
> Here is our problem:
>
> We try to handle thousands of concurrent connections through Mina, and
> what we do is that we put all of the messages goes through Mina
> successfully into a buffer with size 10K and then one by one we get the
> messages from the buffer and insert into single sql server table. However
> under heavy load, our inserts into the database table slows down
> significantly. We actually had no buffer before but at that time, it was
> even worse to insert all those concurrent messages right away into the
> table. We thought buffer would give us time to store the data under heavy
> load and we could get the messages one by one from the buffer and insert
> into the DB. But nowadays, even buffer is not enough for us.
> we are not sure whether the buffer is holding us back or the DB inserts
> but somehow we have to find a way to insert all the concurrent messages
> into that one DB table.
> (the buffer we are using it BoundedFifoBuffer and we use it as
> synchronized buffer)
>
>
> Thanks for your help in advance.
>
> Eray Yuksek
>
>
> E.Y.


Re: sshd - async interface

2014-04-19 Thread Jon V.
You could simply try the write or read on an interval. There are a few
scenarios where aio is use able without NIO. Primarily when you use
blocking read and scheduled non blocking writes.
On Apr 19, 2014 9:58 AM, "Alon Bar-Lev"  wrote:

> On Sat, Apr 19, 2014 at 3:52 PM, Jon V.  wrote:
> >
> > NIO controls and deals with the selectors. Async IO is a part of that but
> > is not the same thing. Async io means that if a write cannot be fully
> > flushed. It will not block until it can be. NIO provides us the events to
> > tell us that data is available in the socket.
>
> Async IO is the ability for a single thread to perform (multiplex) IO
> (connect, read, write, close etc..) for multiple file descriptors.
>
> As far as I know, without NIO you cannot achieve that in Java.
>
> There is no sense in read or write without blocking if you cannot wait
> (vs actively poll) for an event.
>
> > On Apr 19, 2014 4:56 AM, "Alon Bar-Lev"  wrote:
> >
> > > On Sat, Apr 19, 2014 at 10:58 AM, Emmanuel Lécharny <
> elecha...@gmail.com>
> > > wrote:
> > > > Le 4/19/14 9:45 AM, Alon Bar-Lev a écrit :
> > > >> On Sat, Apr 19, 2014 at 10:38 AM, Emmanuel Lécharny <
> > > elecha...@gmail.com> wrote:
> > > >>> Le 4/19/14 9:13 AM, Alon Bar-Lev a écrit :
> > > >>>> Hi,
> > > >>>>
> > > >>>> The mission of async is to avoid having threads at all, or at
> least
> > > O(1).
> > > >>>>
> > > >>>> As you have underline internal/private low level channels for
> socket
> > > >>>> processing, and public high level channels to communicate with
> > > >>>> application, there should be a mechanism for library to request
> wake
> > > >>>> up for these low level channels.
> > > >>>>
> > > >>>> Another option is to avoid using sockets at all within the
> > > >>>> implementation and require application to manage the sockets and
> pipe
> > > >>>> socket data into the library.
> > > >>>>
> > > >>>> I understand this is conceptional change than what we have now,
> but
> > > >>>> this what will enable scale without abusing system threads or have
> > > >>>> nondeterministic behaviour in high load.
> > > >>> There are a few important things you have to know about async and
> > > threads :
> > > >>> - the extra cost for dealing with async connection is around 30%.
> That
> > > >>> all but free
> > > >>> - a standard system can easily deal with a few thousands of threads
> > > >>>
> > > >>> Now, unless you define what is "high load", I don't really see what
> > > kind
> > > >>> of advantage we can get with an async implementation.
> > > >>>
> > > >>> FTR, when MINA was initially created, it was because there was a
> need
> > > >>> for a system supporting potentially ten of thousands of
> connections. Is
> > > >>> that what you are targetting ?
> > > >> Yes, using work threads that are derived per # of CPUs, no more.
> > > >> I am far from the pure "Java" world... but if async IO is 30%
> > > >> insufficient, maybe it worth to use libssh (C) and communicate with
> it
> > > >> using single socket from java, delegating IO outside of java.
> > > > IO are already delegated outside on Java. Eveything IO related is
> > > > written in C and wrapped into Java class.
> > > >
> > > > The extra cost when using NIO is due to the management of SelectorKey
> > > > lists (with the various steps involved when dealing with those
> lists).
> > > >
> > > > All in all, when it comes to process IO, Java does not really add
> some
> > > > extra cost over a plain C implementation. It's not the same story
> when
> > > > using NIO, especially when dealing with many concurrent connections.
> > > >
> > >
> > > So I am confused... Java does not add cost to async IO, but NIO does?
> > > While NIO is the only interface to Java async IO?
> > >
>


Re: sshd - async interface

2014-04-19 Thread Jon V.
NIO controls and deals with the selectors. Async IO is a part of that but
is not the same thing. Async io means that if a write cannot be fully
flushed. It will not block until it can be. NIO provides us the events to
tell us that data is available in the socket.
On Apr 19, 2014 4:56 AM, "Alon Bar-Lev"  wrote:

> On Sat, Apr 19, 2014 at 10:58 AM, Emmanuel Lécharny 
> wrote:
> > Le 4/19/14 9:45 AM, Alon Bar-Lev a écrit :
> >> On Sat, Apr 19, 2014 at 10:38 AM, Emmanuel Lécharny <
> elecha...@gmail.com> wrote:
> >>> Le 4/19/14 9:13 AM, Alon Bar-Lev a écrit :
>  Hi,
> 
>  The mission of async is to avoid having threads at all, or at least
> O(1).
> 
>  As you have underline internal/private low level channels for socket
>  processing, and public high level channels to communicate with
>  application, there should be a mechanism for library to request wake
>  up for these low level channels.
> 
>  Another option is to avoid using sockets at all within the
>  implementation and require application to manage the sockets and pipe
>  socket data into the library.
> 
>  I understand this is conceptional change than what we have now, but
>  this what will enable scale without abusing system threads or have
>  nondeterministic behaviour in high load.
> >>> There are a few important things you have to know about async and
> threads :
> >>> - the extra cost for dealing with async connection is around 30%. That
> >>> all but free
> >>> - a standard system can easily deal with a few thousands of threads
> >>>
> >>> Now, unless you define what is "high load", I don't really see what
> kind
> >>> of advantage we can get with an async implementation.
> >>>
> >>> FTR, when MINA was initially created, it was because there was a need
> >>> for a system supporting potentially ten of thousands of connections. Is
> >>> that what you are targetting ?
> >> Yes, using work threads that are derived per # of CPUs, no more.
> >> I am far from the pure "Java" world... but if async IO is 30%
> >> insufficient, maybe it worth to use libssh (C) and communicate with it
> >> using single socket from java, delegating IO outside of java.
> > IO are already delegated outside on Java. Eveything IO related is
> > written in C and wrapped into Java class.
> >
> > The extra cost when using NIO is due to the management of SelectorKey
> > lists (with the various steps involved when dealing with those lists).
> >
> > All in all, when it comes to process IO, Java does not really add some
> > extra cost over a plain C implementation. It's not the same story when
> > using NIO, especially when dealing with many concurrent connections.
> >
>
> So I am confused... Java does not add cost to async IO, but NIO does?
> While NIO is the only interface to Java async IO?
>


Re: Moving from Mina2 to Mina3

2014-04-13 Thread Jon V.
I am probably not the best person to comment on this.

It is my understanding that mina3 is still in active development. There is
no official release. You shouldn't build production apps with it unless you
are willing to build and go through an extensive testing process.
Hi guys,

I would like to move from Mina2 to Mina3...
I noticed that old api in most cases is not compatible with Mina3.

You can see the protocol implementation in which I use Mina2 here:
https://github.com/vkravets/Fido4Java/tree/master/binkp

Could you specify guide or examples which helps me to move to Mina3?

Also I have one additional question which is related to Mina2 and Mina3:
I have protocol encrypt/decrypt but this is is optional and it should be
performed after connection(I received message in which describing should I
use encryption or not).
Can I performing such behavior using chain Filters. If yes how I can
control state of encryption?

Thanks,
Vladimir


Re: [Support] Mina 2.0.7 improve reliability when there are network error

2014-03-31 Thread Jon V.
TCP works perfectly. If there is a problem. It is elsewhere.

Implementing message delivery confirmation is a part of a higher level
protocol. If the network/TCP is connected; it will be delivered.

In what environment are you expecting TCP sockets to close all the time?

Here is what happening regarding missing packets 39-55.  Those are packets
that probably exist in the native io buffer. No application can read what
is in there? The assumption is that data in there will be written. However
a socket can be closed while data exists in this buffer.
Your higher level proto needs to send back an ACK with a packet number. You
need to handle this yourself.
On Mar 31, 2014 12:22 PM, "TRAN Antoine" 
wrote:

> Hi,
>
> Goal
> I would like to improve the reliability of our program using Mina.
> From the research and tests I have made, it seems:
>
>  1.  TCP reliability is not enough for messages not to be lost.
>  2.  Mina does not offer message sent acknowledgment.
>  3.  Lost of connection can be detected with the IOException that Mina
> will throw in IoHandlerAdapter#exceptionCaught.
>  4.  If the remote socket is closed when writing to it, Mina will throw an
> WriteToClosedSessionException in IoHandlerAdapter#exceptionCaught.
>
> Based on these statements, I have made a program that will use a buffer in
> case Mina cannot send messages. When the reconnection is done, it will
> flush the buffer and then resend as normal.
>
> Problems
> This is my test. I send 100 messages at 1/sec. I removed the ethernet
> cable after the 39th messages, put it back a few seconds later. As a
> consequence, I lost some messages. Here are some elements that might help.
>
>  1.  The written data are from messages 1 to 39 and from 55 to 100 (so
> some messages are lost).
>  2.  The Mina server and client notice an IOException.
>  3.  The Mina client gets the IOException way too late (after the 53th
> message).
>  4.  The WriteToClosedSessionException that is supposed to contain all the
> messages that could not be sent contains only the messages from 55 to 58
> (expected from 40 to 58).
>
> Questions
>
>  1.  Are the above statements correct?
>  2.  Is my workaround a good solution or does Mina already offer a better
> way of keeping messages before sending them in case of network error?
>
> Thank you.
>
> Yours sincerely,
>
> Antoine
>


Re: How to write byte[] to an IoSession

2014-03-12 Thread Jon V.
You are converting an incoming iobuffer to byte[] you need to write an
iobuffer.
On Mar 12, 2014 11:34 AM, "dinesh707"  wrote:

> As shown below I can read the byte[] sent from an IoSession without having
> a
> protocol decoder.
>
> IoBuffer in = (IoBuffer) message;
> byte[] inBytes = in.array();
> int length = inBytes[0];
> inBytes = Arrays.copyOfRange(inBytes, 1, length + 1);
> ByteString incomingMessage = ByteString.copyFrom(inBytes);
>
> But when I try to do
>
> someIoSession.write(incomingMessage.toByteArray());
>
> I get the following error.
>
> Don't know how to handle message of type .  Are you missing a protocol
> encoder?
>
> How can i just write the bytes into an IoSession ??
>
>
>
>
> --
> View this message in context:
> http://apache-mina.10907.n7.nabble.com/How-to-write-byte-to-an-IoSession-tp41542.html
> Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
>


Re: Status on DIRMINA-934 and 3.0 relase

2014-03-11 Thread Jon V.
Paul,

This would need aggressive testing as locks do not cause memory
synchronization; this in itself can break code that does not synchronize or
use volatile variables.  I use Semaphores often; always with a plan to
force object synchronization.  For example: ByteBuffer position/limit etc
are not volatile and must be synchronized to ensure that the positioning is
correct.

Semaphore's current count is also non volatile; that is how it quickly
decides in the tryLock() phase.

To recap, it may work but should be tested extensively.

-Jon


On Mon, Mar 10, 2014 at 7:26 PM, Mondain  wrote:

> Is https://issues.apache.org/jira/browse/DIRMINA-934 dead or just
> forgotten? I'm still using a patched version in Red5 and would love to see
> it committed. Lastly, whats the current status of a 3.0 release? I'd like
> to get started porting the our I/O code to work with it.
>
> Regards,
> Paul
>
> --
> http://gregoire.org/
> http://code.google.com/p/red5/
>


Re: Separate Threads for sending and receiving

2014-02-22 Thread Jon V.
Instead of relying on logging; I would setup a stress test to measure
completed commands/s and use that as a foundation for trying other
procedures.


On Sat, Feb 22, 2014 at 7:03 AM, Max Larsson
wrote:

> Hi,
>
> >> 
> >>
>
>> In my IoHandler i receive the desired message and write out the response
>>> to session.write. But it is not immediately written out. During my
>>> process of the message additional message are received and process
>>> before my response message is delivered.
>>>
>>
>> It all depends on the session processing the incoming message. This is a
>> multi-threaded framework, messages comming from dfferent sessions may be
>> processed in //.
>>
>
> OK because, i implement the client i only have one session, thus this
> doesn't complicate my issue.
>
>  Now i figured out that only one thread handles read/write request.
>>>
>> Absolutely.
>>
>>  And
>>> the read request is processed before any write request?
>>>
>>
>> depends. If the socket is full when the thread is trying to write into
>> it, then it give up, and a new incoming message might be processed
>> before the write can be done. Eventually, a lot of messages can be
>> stacked waiting for being written.
>>
>
>  So how can i
>>> either have a separate Thread for sending and receiving.
>>>
>>
>> You can use an Executor in the chain, even two executors if needed (one
>> for reads, one for writes). But at the nend of the day, it does not
>> somlve your issue.
>>
>>  Or alternative
>>> how to tell the NioSocketprocess to take priority processing of write
>>> requests?
>>>
>>
>> You can idle the read while the write is not processed. The way it works
>> woudl be something like :
>>
>> - process a read (in the handler)
>> - idle the read (session.suspendRead())
>> - write the response
>>
>> Then in the handler, react on the messageSent event :
>>
>> - process the messageSent event
>> - un-idle the read (session.resumeRead())
>>
>> You now can process a new read.
>>
>> Think twice before implementing such a logic though !!! I would question
>> the fact that the client is sending messages but not reading the
>> response fast enough...
>>
>
> You correct, your purposed solution doesn't solve my issue. At least
> i tried the ExecutorFilter, the suspendRead solution feels already from
> the reading ugly, so i didn't give it try. And because i'm the client
> i think i have a performance problem. But my investigation shows me
> that from receiving the command in my IoHandler to writing the response
> with session.write i need around 2 ms. But than it takes about 70 ms to
> get a logging about form the NioProcessor saying it send the message.
>
> Normally the NioProcess will not received any additional commands from
> between the first and sending my response. But under heavy load it will
> receive additional commands before sending my response and thus delay
> it additional about some ms.
>
> My goal is to get this 70ms as low as possible, and you say the cause
> for the long processing time is that the socket is full? Can a socket be
> full because of message collisions on the wire?
>
> Oh by the way i know i can get faster, because in raw cases the 70ms
> drop down to 2ms. Thus the whole command response cycle is processed
> in about 4ms.
>
> best regards
>
> Max
>
> --
> _
>
> http://facilityboss.biz
> http://facebook.com/facilityboss
> _
>
> Max Larsson
> facilityboss GmbH
> Rheinstrasse 75, 64295 Darmstadt / Germany
> Handelsregister Darmstadt, HRB 86193
> Geschäftsführer: Dipl.-Inform. Max Lars Robert Larsson
>
> Mobil: +49 179 2184428
> Email: max.lars...@facilityboss.biz
>


Re: handling a slow client

2013-11-25 Thread Jon V.
You should never assume that all of your data is available. If you work
with this, you can handle any speed client. I test everything against
simulated invalid packets and random latency.
On Nov 25, 2013 9:38 AM, "Andrew Pennebaker"  wrote:

> This is a good edge case to consider, as some script kiddy tools for
> attacking websites behave this way.
>
>
> On Fri, Nov 22, 2013 at 4:00 PM, Binole, Bill <
> william.j.bin...@questdiagnostics.com> wrote:
>
> > I was wondering how to handle a slow client.  So say my client writes 100
> > bytes and then 5 seconds later writes another 100 bytes.  What is being
> > sent is delimited with a start and end block that I am checking for to
> > insure I have a full message.  I have written a decoder based on the
> > CumulativeProtocolDecoder that works just fine except for the case of a
> > slow client.  In this case the buffer is drained before the end block is
> > received and it is causing a bogus error condition.  Is there a way to
> > handle this within the decoder?
> >
> > Bill
> >
> > __
> > The contents of this message, together with any attachments, are intended
> > only for the use of the person(s) to which they are addressed and may
> > contain confidential and/or privileged information. Further, any medical
> > information herein is confidential and protected by law. It is unlawful
> for
> > unauthorized persons to use, review, copy, disclose, or disseminate
> > confidential medical information. If you are not the intended recipient,
> > immediately advise the sender and delete this message and any
> attachments.
> > Any distribution, or copying of this message, or any attachment, is
> > prohibited.
>
>
>
>
> --
> Cheers,
>
> Andrew Pennebaker
> apenneba...@42six.com
>


Re: Can MINA create proxy servers?

2013-11-22 Thread Jon V.
I was thinking about the Http lib. I didn't remember a proxy in there.

Thanks.
On Nov 22, 2013 3:32 PM, "Emmanuel Lécharny"  wrote:

> Le 11/22/13 9:20 PM, Jon V. a écrit :
> > I imagine you could build a proxy in Mina. However I don't believe any
> > prebuilt proxies exist. May be easier to just use nginx.
>
>
> http://mina.apache.org/mina-project/xref-test/org/apache/mina/example/proxy/ProxyTestClient.html
>
> and
>
>
> http://mina.apache.org/mina-project/xref/org/apache/mina/proxy/ProxyConnector.html
>
> It's included in the Mina core lib.
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>


Re: Can MINA create proxy servers?

2013-11-22 Thread Jon V.
I imagine you could build a proxy in Mina. However I don't believe any
prebuilt proxies exist. May be easier to just use nginx.
On Nov 22, 2013 3:12 PM, "Andrew Pennebaker"  wrote:

> I ask, because I'm using Mina to spin up little test HTTP/FTP servers, to
> test a web crawler. Would be nice to spin up proxy servers, to test proxy
> support in the crawler.
>
>
> On Fri, Nov 22, 2013 at 12:02 PM, Jon V.  wrote:
>
> > I don't see why not. I wouldn't recommend it however.
> >
> > Proxy servers need to be more bare metal.
> >
> > Nginx has a proxy module you should look at.
> > On Nov 22, 2013 11:59 AM, "Andrew Pennebaker" 
> > wrote:
> >
> > > That would be cool!
> > >
> > > --
> > > Cheers,
> > >
> > > Andrew Pennebaker
> > > apenneba...@42six.com
> > >
> >
>
>
>
> --
> Cheers,
>
> Andrew Pennebaker
> apenneba...@42six.com
>


Re: Can MINA create proxy servers?

2013-11-22 Thread Jon V.
I don't see why not. I wouldn't recommend it however.

Proxy servers need to be more bare metal.

Nginx has a proxy module you should look at.
On Nov 22, 2013 11:59 AM, "Andrew Pennebaker"  wrote:

> That would be cool!
>
> --
> Cheers,
>
> Andrew Pennebaker
> apenneba...@42six.com
>


Re: IoSession write method thread safe?

2013-11-21 Thread Jon V.
I would imagine this to be true. The normal use case is request and
response. Additional synchronization makes the code run slower in that
scenario. I would suggest synchronizing critical paths.

I have to synchronize write paths for the same reason where one input may
write to dozens of other sockets.
On Nov 21, 2013 10:23 AM, "Alexandros Touloupis" 
wrote:

> Hello all,
>
> I am using mina 2.0.8 since I needed a patch included in this release.
>
> I face the following problem:
>
> The concept of the application is to "multiplex" inbound to outbound
> connections in MINA. This means that there might be 2 incoming connections
> that are multiplexed in one outbound connection. During my tests i randomly
> see this exception:
>
> java.nio.InvalidMarkException
> at java.nio.Buffer.reset(Buffer.java:298) ~[?:1.7.0_40]
> at
>
> org.apache.mina.core.buffer.AbstractIoBuffer.reset(AbstractIoBuffer.java:414)
> ~[mina-core-2.0.8-PATCHED.jar:?]
> at
>
> org.apache.mina.core.polling.AbstractPollingIoProcessor.writeBuffer(AbstractPollingIoProcessor.java:926)
> ~[mina-core-2.0.8-SNAPSHOT.jar:?]
> at
>
> org.apache.mina.core.polling.AbstractPollingIoProcessor.flushNow(AbstractPollingIoProcessor.java:844)
> [mina-core-2.0.8-SNAPSHOT.jar:?]
> at
>
> org.apache.mina.core.polling.AbstractPollingIoProcessor.flush(AbstractPollingIoProcessor.java:772)
> [mina-core-2.0.8-SNAPSHOT.jar:?]
> at
>
> org.apache.mina.core.polling.AbstractPollingIoProcessor.access$700(AbstractPollingIoProcessor.java:67)
> [mina-core-2.0.8-SNAPSHOT.jar:?]
> at
>
> org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1112)
> [mina-core-2.0.8-SNAPSHOT.jar:?]
> at
>
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
> [mina-core-2.0.8-SNAPSHOT.jar:?]
> at
>
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> [?:1.7.0_40]
> at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> [?:1.7.0_40]
> at java.lang.Thread.run(Thread.java:724) [?:1.7.0_40]
>
> After some investigation i noticed that this happened when 2 threads
> decided to write to the same IoSession a message the same time. My
> assumption is that the #IoSession.write method is not thread safe, thus i
> synchronized the session instance before executing the write method in my
> handlers and up until now i haven't faced the same issue. Is my assumption
> valid?
>
> Thank you in advance,
> Alex
>


Re: IoSession write method thread safe?

2013-11-21 Thread Jon V.
Synchronized is important to update the thread caches. More so when
different sessions are bound to different threads.
On Nov 21, 2013 10:45 AM, "Alexandros Touloupis" 
wrote:

> Thanks for the reply!
>
> Yes I agree that synchronizing to the whole IoSession instance each time
> for writing, is brutal. I am thinking on including a writing lock as a
> session attribute in each session that will be initialized on
> sessionCreated events.
>
> Cheers!
> Alex
>
>
> On Thu, Nov 21, 2013 at 4:28 PM, Jon V.  wrote:
>
> > I would imagine this to be true. The normal use case is request and
> > response. Additional synchronization makes the code run slower in that
> > scenario. I would suggest synchronizing critical paths.
> >
> > I have to synchronize write paths for the same reason where one input may
> > write to dozens of other sockets.
> > On Nov 21, 2013 10:23 AM, "Alexandros Touloupis" 
> > wrote:
> >
> > > Hello all,
> > >
> > > I am using mina 2.0.8 since I needed a patch included in this release.
> > >
> > > I face the following problem:
> > >
> > > The concept of the application is to "multiplex" inbound to outbound
> > > connections in MINA. This means that there might be 2 incoming
> > connections
> > > that are multiplexed in one outbound connection. During my tests i
> > randomly
> > > see this exception:
> > >
> > > java.nio.InvalidMarkException
> > > at java.nio.Buffer.reset(Buffer.java:298) ~[?:1.7.0_40]
> > > at
> > >
> > >
> >
> org.apache.mina.core.buffer.AbstractIoBuffer.reset(AbstractIoBuffer.java:414)
> > > ~[mina-core-2.0.8-PATCHED.jar:?]
> > > at
> > >
> > >
> >
> org.apache.mina.core.polling.AbstractPollingIoProcessor.writeBuffer(AbstractPollingIoProcessor.java:926)
> > > ~[mina-core-2.0.8-SNAPSHOT.jar:?]
> > > at
> > >
> > >
> >
> org.apache.mina.core.polling.AbstractPollingIoProcessor.flushNow(AbstractPollingIoProcessor.java:844)
> > > [mina-core-2.0.8-SNAPSHOT.jar:?]
> > > at
> > >
> > >
> >
> org.apache.mina.core.polling.AbstractPollingIoProcessor.flush(AbstractPollingIoProcessor.java:772)
> > > [mina-core-2.0.8-SNAPSHOT.jar:?]
> > > at
> > >
> > >
> >
> org.apache.mina.core.polling.AbstractPollingIoProcessor.access$700(AbstractPollingIoProcessor.java:67)
> > > [mina-core-2.0.8-SNAPSHOT.jar:?]
> > > at
> > >
> > >
> >
> org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1112)
> > > [mina-core-2.0.8-SNAPSHOT.jar:?]
> > > at
> > >
> > >
> >
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
> > > [mina-core-2.0.8-SNAPSHOT.jar:?]
> > > at
> > >
> > >
> >
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> > > [?:1.7.0_40]
> > > at
> > >
> > >
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> > > [?:1.7.0_40]
> > > at java.lang.Thread.run(Thread.java:724) [?:1.7.0_40]
> > >
> > > After some investigation i noticed that this happened when 2 threads
> > > decided to write to the same IoSession a message the same time. My
> > > assumption is that the #IoSession.write method is not thread safe,
> thus i
> > > synchronized the session instance before executing the write method in
> my
> > > handlers and up until now i haven't faced the same issue. Is my
> > assumption
> > > valid?
> > >
> > > Thank you in advance,
> > > Alex
> > >
> >
>


Re: Unable to open more than 1000 ports in Mina Client

2013-09-30 Thread Jon V.
>.But when 1000 clients connect simultaneously more than
>50% of the connections will not respond with in 3 seconds and so the
>connection is closed by the client.

So it sounds to me like he was connecting all of them at the same time.
 Hence my backlog statement.  If he connected them 5-10 at a time; I am
sure it would work normally.


On Mon, Sep 30, 2013 at 11:59 AM, Jon V.  wrote:

> I've seen this before and it was tightly bound to the Acceptor backlog for
> me.  My desktop is Win 2008 r2 and I can get 18,000 tcp connections in Java.
>
> Selectors for some reason are very expensive in Windows. (maybe because
> they are not totally independent of each other).  Where I can use 8 on
> Linux; there is a significant performance problem with greater than 3 on
> Windows.
>
>
> On Mon, Sep 30, 2013 at 11:54 AM, Emmanuel Lécharny 
> wrote:
>
>> Le 9/30/13 8:52 AM, Jon V. a écrit :
>> > NioSocketAcceptor( number ) creates N threads.  > 10 is a problem in
>> most
>> > cases.  The default backlog for a SocketAcceptor in Java is 50.  I have
>> > mine set to 200 to prevent dropped "accept" requests.  Each time a
>> socket
>> > attempts to connect it gets put in the backlog waiting for an "accept"
>> to
>> > be called.  If this buffer overflows the TCP connections drop in a bad
>> way.
>>
>> As I already said in a previous mail, this 1000 port limit is extremelly
>> weird.
>>
>> In any case, this has nothing to do with MINA and any setting on MINA.
>>
>> Chck :
>> - your firewall
>> - your router setting.
>> - consider using a decent OS instead of Windows 2008 which is, all in
>> all, just 6 years old...
>>
>>
>> --
>> Regards,
>> Cordialement,
>> Emmanuel Lécharny
>> www.iktek.com
>>
>>
>


Re: Unable to open more than 1000 ports in Mina Client

2013-09-30 Thread Jon V.
I've seen this before and it was tightly bound to the Acceptor backlog for
me.  My desktop is Win 2008 r2 and I can get 18,000 tcp connections in Java.

Selectors for some reason are very expensive in Windows. (maybe because
they are not totally independent of each other).  Where I can use 8 on
Linux; there is a significant performance problem with greater than 3 on
Windows.


On Mon, Sep 30, 2013 at 11:54 AM, Emmanuel Lécharny wrote:

> Le 9/30/13 8:52 AM, Jon V. a écrit :
> > NioSocketAcceptor( number ) creates N threads.  > 10 is a problem in most
> > cases.  The default backlog for a SocketAcceptor in Java is 50.  I have
> > mine set to 200 to prevent dropped "accept" requests.  Each time a socket
> > attempts to connect it gets put in the backlog waiting for an "accept" to
> > be called.  If this buffer overflows the TCP connections drop in a bad
> way.
>
> As I already said in a previous mail, this 1000 port limit is extremelly
> weird.
>
> In any case, this has nothing to do with MINA and any setting on MINA.
>
> Chck :
> - your firewall
> - your router setting.
> - consider using a decent OS instead of Windows 2008 which is, all in
> all, just 6 years old...
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>


Re: Unable to open more than 1000 ports in Mina Client

2013-09-30 Thread Jon V.
NioSocketAcceptor( number ) creates N threads.  > 10 is a problem in most
cases.  The default backlog for a SocketAcceptor in Java is 50.  I have
mine set to 200 to prevent dropped "accept" requests.  Each time a socket
attempts to connect it gets put in the backlog waiting for an "accept" to
be called.  If this buffer overflows the TCP connections drop in a bad way.


On Mon, Sep 30, 2013 at 11:40 AM, praveen wrote:

> i have set the backlog to 12 but still i have the same problem
>
>
>
> --
> View this message in context:
> http://apache-mina.10907.n7.nabble.com/Unable-to-open-more-than-1000-ports-in-Mina-Client-tp39936p39962.html
> Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
>


Re: Unable to open more than 1000 ports in Mina Client

2013-09-30 Thread Jon
Try increasing the backlog on the acceptor.

Sent from my iPhone

> On Sep 30, 2013, at 10:31 AM, praveen  wrote:
> 
> Hi,
> 
> I have the same problem with the mina server. I am running on windows 2008
> with 32 cores.Once the connections is established i need to send the reply
> back in 3 seconds .But when 1000 clients connect simultaneously more than
> 50% of the connections will not respond with in 3 seconds and so the
> connection is closed by the client.
> 
> I tried increasing the NIOProcess to 200 but still the same problem exists.
> 
> Below is the code 
> 
> IoAcceptor acceptor = new NioSocketAcceptor(200);
>acceptor.getFilterChain().addLast("logger", new LoggingFilter());
>acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new
> HexBytesProtocolfactory(Charset.forName("UTF-8";
>acceptor.setHandler(new MinaServerHandler(errorHexcodeList,
> errorDescList));
>acceptor.bind(new InetSocketAddress(this.portNo.intValue()));
>logger.debug("Server started on port " + this.portNo + "..");
>logger.info("Server started on port " + this.portNo + "..");
>acceptor.getSessionConfig().setReadBufferSize(2048);
>acceptor.getSessionConfig().setIdleTime(IdleStatus.READER_IDLE, 10);
>acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 60);
> 
> Can you help me please .Its very urgent
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://apache-mina.10907.n7.nabble.com/Unable-to-open-more-than-1000-ports-in-Mina-Client-tp39936p39960.html
> Sent from the Apache MINA User Forum mailing list archive at Nabble.com.


Re: Multithreaded UDP server vs. OrderedThreadPoolExecutor

2013-09-25 Thread Jon V.
Depends on what aspect of asynchronous you are looking for. The sockets are
always async.  If you have a bunch of ioprocessors then you have
concurrency where more than one message can be processed at any given time.
On Sep 25, 2013 6:15 AM, "Christian Hammers"  wrote:

> Hello
>
> On Tue, 24 Sep 2013 11:51:04 -0700
> Emmanuel Lécharny  wrote:
>
> > Le 9/24/13 9:47 AM, Christian Hammers a écrit :
> > > Hello
> > >
> > > I've written a server for a proprietary UDP protocol that needs to
> answer with
> > > exactly one packet for every incoming packet. All packets are
> independent from
> > > each other so that I like to have each one handled asynchronously by a
> > > different thread from a pool with a certain maximum size.
> > >
> > > So far I used this:
> > >
> > > FooCodec codec = new FooCodec(); // encoder and decoder in one
> class
> > > InetSocketAddress local = new InetSocketAddress(port);
> > >
> > > acceptor = new NioDatagramAcceptor();
> > > acceptor.getFilterChain().addLast("executor", new
> ExecutorFilter(maxThreads));
> > > acceptor.getFilterChain().addLast("codec", new
> ProtocolCodecFilter(codec, codec));
> > > acceptor.setHandler(handler);
> > > acceptor.bind(local);
> > >
> > > At first it seemed that each incoming UDP package, due to its
> stateless nature,
> > > creates a different Mina "session" and each Mina "session" runs in its
> own
> > > thread so that the default ExecutorFilter implementation
> > > OrderedThreadPoolExecutor is fine as I certainly don't want the
> session closed
> > > if there is still a response before it in the queue.
> >
> > That's not what is currently happening. MINA creates a session for each
> > IP address, so if all your UDP messages are issued by one single machine
> > using one IP address, then all the UDP messages will be processed by the
> > same thread.
>
> Ah! They are indeed all coming from the same IP+Port.
> (I used to do a "session.write(message); session.close()" in my
> messageReceived()
> method so it seemed to be different sessions but that was probably a wrong
> approach as well)
>
>
> > Adding an executor in the chain just make it likely that a separate
> > thread will process each UDP message, but the session remains shared.
> >
> > That explains what you see.
>
> OK
>
> > Just get rid of the executor, and increase the number of IoProcessor,
> > you will be able to spread the load on many threads, and each new UDP
> > message will be completely processed before the next UDP message can
> > start to be processed.
>
> How can I increase the number of IoProcessor? Unlike the
> NioSocketAcceptor, the
> NioDatagramAcceptor constructor has no processorCount argumment.
>
> But regarding your last half sentence: Do I understand correctly that each
> IoProcessor
> thread processes one message after the other but as I can have several of
> the
> IoProcessor threads, the whole application will still be able to handle
> incoming request "asynchronously"?
>
> Best Regards,
>
> -christian-
>


Re: Multithreaded UDP server vs. OrderedThreadPoolExecutor

2013-09-24 Thread Jon V.
The first thing I would do would be to disable the executor and try again.
You could be encountering some sort of deadlock.
On Sep 24, 2013 12:47 PM, "Christian Hammers" 
wrote:

> Hello
>
> I've written a server for a proprietary UDP protocol that needs to answer
> with
> exactly one packet for every incoming packet. All packets are independent
> from
> each other so that I like to have each one handled asynchronously by a
> different thread from a pool with a certain maximum size.
>
> So far I used this:
>
> FooCodec codec = new FooCodec(); // encoder and decoder in one
> class
> InetSocketAddress local = new InetSocketAddress(port);
>
> acceptor = new NioDatagramAcceptor();
> acceptor.getFilterChain().addLast("executor", new
> ExecutorFilter(maxThreads));
> acceptor.getFilterChain().addLast("codec", new
> ProtocolCodecFilter(codec, codec));
> acceptor.setHandler(handler);
> acceptor.bind(local);
>
> At first it seemed that each incoming UDP package, due to its stateless
> nature,
> creates a different Mina "session" and each Mina "session" runs in its own
> thread so that the default ExecutorFilter implementation
> OrderedThreadPoolExecutor is fine as I certainly don't want the session
> closed
> if there is still a response before it in the queue.
>
> Now under a bit of load, one session was a bit slower and hanging for 1,5s
> and
> it suddenly happened that multiple UDP packets were put into the same
> Mina "session" which lead to the following log messages:
>
>   2013-09-24 10:56:02,910 DEBUG
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor   :
> Adding event MESSAGE_RECEIVED to session 17529
> Queue : [MESSAGE_RECEIVED, , MESSAGE_RECEIVED, , MESSAGE_RECEIVED ... ]
> (OrderedThreadPoolExecutor.java:431)
>
> This now completely destroys the asynchronous behaviour as all packeges
> had to wait
> for the first one in the queue even if there were several executor threads
> idling
> around!
>
> How should I fix this problem? Using an "UnorderedThreadPoolExecutor?
> Or setting acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE,
> 0);
> Or by somehow else force the creation of a Mina "session" for each UDP
> packet?
>
> Best Regards
>
> -christian-
>
>
> P.S.: http://mina.apache.org/mina-project/documentation.html contains a
>   links to a "UDP Tutorial" which sadly refers to a page that does
>   only have APR and Serial tutorials.
>


RE: EXT :Re: Trouble with messageReceived()

2013-09-16 Thread Jon V.
The ProtocolCodecFilter works on batches instead of stream based. You have
to be careful when you use it to ensure that you obtained all of the
processed messages. This could explain the dropped messages you are seeing.
On Sep 16, 2013 3:20 PM, "Karrys, Michael (IS)"  wrote:

> Thanks. Knew it was something simple. I added the following and it now
> works.
>connector.getFilterChain().addLast(
> "codec",
> new ProtocolCodecFilter(
> new ObjectSerializationCodecFactory()));
> connector.getFilterChain().addLast("logger", new LoggingFilter());
>
> But it drops messages. The SumUp example does not seem to drop messages
> when I changed it to use the ObjectSerializationCodecFactory but I will
> have to verify that.
>
> -Original Message-
> From: Jon V. [mailto:sybersn...@gmail.com]
> Sent: Monday, September 16, 2013 12:25 PM
> To: users@mina.apache.org
> Subject: EXT :Re: Trouble with messageReceived()
>
> On the client you are writing a hashmap to the session. I don't see a
> filter which turns the hashmap into a IoBuffer?  Only IoBuffer can be
> written to the socket directly.
> On Sep 16, 2013 1:12 PM, "Karrys, Michael (IS)" 
> wrote:
>
> > I was wondering if someone could look at this and tell me what I am
> > doing wrong. I don't seem to be getting the messageReceived() called
> > on either the client or the server code. I have been able to get sumup
> > example to run and I used code from that example to mashup this test
> > code. I am rung OS/X with java 7 using mina 2.0.7. The logger shows
> > the CREATED, OPENNED, and CLOSED events for the session but the
> > messageReceived() routine never seems to be called. Is there something
> simple I am missing here?
> >
> > Thanks,
> > Mike Karrys
> > mike.kar...@ngc.com
> >
> > Server Code:
> >
> > public class Main extends IoHandlerAdapter {
> >
> > private static final int SERVER_PORT = 8080;
> > private final static Logger LOGGER =
> > LoggerFactory.getLogger(org.jeuron.test.mina.fl.server.Main.class);
> >
> > public void init() throws IOException {
> > NioSocketAcceptor acceptor = new NioSocketAcceptor();
> >
> > // Prepare the service configuration.
> > acceptor.getFilterChain().addLast(
> > "codec",
> > new ProtocolCodecFilter(
> > new ObjectSerializationCodecFactory()));
> >
> > acceptor.getFilterChain().addLast("logger", new
> > LoggingFilter());
> >
> > acceptor.setHandler(this);
> > acceptor.bind(new InetSocketAddress(SERVER_PORT));
> >
> > System.out.println("Listening on port " + SERVER_PORT);
> >
> > }
> >
> > public Map process(Map record) {
> > int count = (Integer) record.get(Field.COUNT);
> > int length = (Integer) record.get(Field.LENGTH);
> > String input = (String) record.get(Field.CONTENTS);
> > StringBuilder output = new StringBuilder();
> >
> > System.out.print("Processing(" + (length + 1) + ")\r");
> > for (int i = input.length(); i > 0; i--) {
> > output.append(input.charAt(i - 1));
> > }
> > record.put(Field.CONTENTS, output.toString());
> >
> > if (count == length) {
> > System.out.println("\nFinished Processing " + (count + 1));
> > }
> >
> > return record;
> > }
> >
> > @Override
> > public void sessionOpened(IoSession session) {
> > LOGGER.info("sessionOpened.");
> > session.getConfig().setIdleTime(IdleStatus.BOTH_IDLE, 60);
> > }
> >
> > @Override
> > public void messageReceived(IoSession session, Object message) {
> > Map input;
> > Map output;
> >
> > LOGGER.info("messageReceived(" + message + ")");
> > if (message instanceof Map) {
> > input = (Map) message;
> > output = process(input);
> > session.write(output);
> > }
> > }
> >
> > @Override
> > public void sessionIdle(IoSession session, IdleStatus status) {
> > LOGGER.info("Disconnecting the idle.");
> > session.close(true);
> > }
> >
> > @Override
> > public void exceptionCaught(IoSession sessi

Re: Trouble with messageReceived()

2013-09-16 Thread Jon V.
On the client you are writing a hashmap to the session. I don't see a
filter which turns the hashmap into a IoBuffer?  Only IoBuffer can be
written to the socket directly.
On Sep 16, 2013 1:12 PM, "Karrys, Michael (IS)"  wrote:

> I was wondering if someone could look at this and tell me what I am doing
> wrong. I don't seem to be getting the messageReceived() called on either
> the client or the server code. I have been able to get sumup example to run
> and I used code from that example to mashup this test code. I am rung OS/X
> with java 7 using mina 2.0.7. The logger shows the CREATED, OPENNED, and
> CLOSED events for the session but the messageReceived() routine never seems
> to be called. Is there something simple I am missing here?
>
> Thanks,
> Mike Karrys
> mike.kar...@ngc.com
>
> Server Code:
>
> public class Main extends IoHandlerAdapter {
>
> private static final int SERVER_PORT = 8080;
> private final static Logger LOGGER =
> LoggerFactory.getLogger(org.jeuron.test.mina.fl.server.Main.class);
>
> public void init() throws IOException {
> NioSocketAcceptor acceptor = new NioSocketAcceptor();
>
> // Prepare the service configuration.
> acceptor.getFilterChain().addLast(
> "codec",
> new ProtocolCodecFilter(
> new ObjectSerializationCodecFactory()));
>
> acceptor.getFilterChain().addLast("logger", new LoggingFilter());
>
> acceptor.setHandler(this);
> acceptor.bind(new InetSocketAddress(SERVER_PORT));
>
> System.out.println("Listening on port " + SERVER_PORT);
>
> }
>
> public Map process(Map record) {
> int count = (Integer) record.get(Field.COUNT);
> int length = (Integer) record.get(Field.LENGTH);
> String input = (String) record.get(Field.CONTENTS);
> StringBuilder output = new StringBuilder();
>
> System.out.print("Processing(" + (length + 1) + ")\r");
> for (int i = input.length(); i > 0; i--) {
> output.append(input.charAt(i - 1));
> }
> record.put(Field.CONTENTS, output.toString());
>
> if (count == length) {
> System.out.println("\nFinished Processing " + (count + 1));
> }
>
> return record;
> }
>
> @Override
> public void sessionOpened(IoSession session) {
> LOGGER.info("sessionOpened.");
> session.getConfig().setIdleTime(IdleStatus.BOTH_IDLE, 60);
> }
>
> @Override
> public void messageReceived(IoSession session, Object message) {
> Map input;
> Map output;
>
> LOGGER.info("messageReceived(" + message + ")");
> if (message instanceof Map) {
> input = (Map) message;
> output = process(input);
> session.write(output);
> }
> }
>
> @Override
> public void sessionIdle(IoSession session, IdleStatus status) {
> LOGGER.info("Disconnecting the idle.");
> session.close(true);
> }
>
> @Override
> public void exceptionCaught(IoSession session, Throwable cause) {
> session.close(true);
> }
>
> public static void main(String[] args) throws Exception {
> Main main = new Main();
> main.init();
> }
> }
>
> Client Code:
>
> public class Main extends IoHandlerAdapter {
>
> private final static Logger LOGGER =
> LoggerFactory.getLogger(org.jeuron.test.mina.fl.client.Main.class);
> private static final String HOSTNAME = "localhost";
> private static final int PORT = 8080;
> private NioSocketConnector connector;
> private IoSession session;
> static char[] letter = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
> 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
> 'Y', 'Z'};
> private long startTime = 0;
> private long endTime = 0;
> private int maxSent = 0;
> private int receivedRecords = 0;
> private long totalBytes = 0;
> private int recordLengthValue = 0;
> private int recordCountValue = 0;
>
> public String readInput(String prompt) throws IOException {
> String input = null;
>
> System.out.println(prompt);
> BufferedReader br = new BufferedReader(new
> InputStreamReader(System.in));
> input = br.readLine();
>
> return input;
> }
>
> public boolean init() throws Exception {
> SocketAddress address = new InetSocketAddress(HOSTNAME, PORT);
> LOGGER.info("Main:init() address[" + address + "]");
>
> connector = new NioSocketConnector();
> connector.setHandler(this);
> for (;;) {
> try {
> ConnectFuture future = connector.connect(new
> InetSocketAddress(HOSTNAME, PORT));
> future.awaitUninterruptibly();
> session = future.getSession();
> break;
>} catch (RuntimeIoException e) {
> System.err.println("Failed to connect.");

Re: MINA support for WebSockets?

2013-09-04 Thread Jon
I am not the person to ask regarding Mina's future plans. Emmanuel?

WebSocket starts with an http request and performs an upgrade command. After 
that it is just a minimal frame data.  

Sent from my iPhone

On Sep 4, 2013, at 8:15 PM, Mark Phillips  wrote:

> HTTP's not my interest.  Almost identically to Dhruv's messages in the 
> archived exchange from last year, I want a WebSocket filter which will 
> process the connect handshake, then be invisible, so that existing MINA-based 
> servers can handle WebSocket clients without other modification.  So my 
> questions are, what's the status of the code which Dhruv contributed 12 
> months ago?  Is that going to become part of a future release?  Are we free 
> to use it?  Does the MINA roadmap include that code, or has that code been 
> abandoned?  Is there some other plan for WS support on the horizon?
> 
> --Mark
> 
> 
> On Sep 4, 2013, at 3:33 PM, Jon V.  wrote:
> 
>> The http implementation hasn't received any love lately as far as I know.
>> It is not for needing a bit of work. Why not take the code and integrate it
>> yourself?  WebSockets are not terribly complicated.
>> On Sep 4, 2013 11:36 AM, "Mark Phillips"  wrote:
>> 
>>> The Users and Dev list archives contain year-old exchanges with Dhruv
>>> Chopra of ShepHertz in which the ShepHertz company offers to donate
>>> WebSocket protocol filters to MINA.  I see that code in the developers'
>>> JIRA.  But that exchange seems to have ended after just a few messages, and
>>> it doesn't look like the donated code has subsequently been integrated into
>>> a release.  What are MINA's plans to support WebSockets?  I think it's
>>> clear that ability to add WebSockets IO to existing MINA-based server apps
>>> is attractive for many users.
>>> 
>>> Thanks!
>>> 
>>> --Mark
> 


Re: MINA support for WebSockets?

2013-09-04 Thread Jon V.
The http implementation hasn't received any love lately as far as I know.
It is not for needing a bit of work. Why not take the code and integrate it
yourself?  WebSockets are not terribly complicated.
On Sep 4, 2013 11:36 AM, "Mark Phillips"  wrote:

> The Users and Dev list archives contain year-old exchanges with Dhruv
> Chopra of ShepHertz in which the ShepHertz company offers to donate
> WebSocket protocol filters to MINA.  I see that code in the developers'
> JIRA.  But that exchange seems to have ended after just a few messages, and
> it doesn't look like the donated code has subsequently been integrated into
> a release.  What are MINA's plans to support WebSockets?  I think it's
> clear that ability to add WebSockets IO to existing MINA-based server apps
> is attractive for many users.
>
> Thanks!
>
> --Mark


Re: Send/Receive IoBuffer

2013-09-03 Thread Jon V.
Change what I gave you to conform with MINA.  I simply wrote everything in
notepad to give you an idea.


On Tue, Sep 3, 2013 at 1:31 AM, Luciano Coelho wrote:

> Thanks a lot for you answer, I will study about filters and try your
> solution too.
>
> Thanks too much really.
>
> -Mensagem original-
> De: Jon V. [mailto:sybersn...@gmail.com]
> Enviada em: segunda-feira, 2 de setembro de 2013 23:54
> Para: users@mina.apache.org
> Assunto: Re: Send/Receive IoBuffer
>
> This is better:  I am not going to use the correct API but you can get the
> idea.
>
> Create a Filter called CompoundBufferFilter
>
> filter_received( ByteBuffer source, IoSession session, Filter next ) {
> ByteBuffer buffering = session.getAttribute( SOME_PROPERTY_BUFFER_NAME );
>
>  if( buffering == null )
>  {
> buffering = ByteBuffer.allocate( some size );  }
>
>  buffering.put( source );
>  buffering.flip();
>
>  next.received( buffering, session );
> }
>
> This will compound buffer incoming data.
>
> logic_received( ByteBuffer source, IoSession session ) { while(
> source.hasRemaining() ) { source.mark(); if( source.remaining < 4 ) {
> source.reset();
> return;
> }
>  int size = source.getInt();
>  if( source.remaining < size )
> {
> source.reset();
> return;
> }
>  String data = new String( buffering.array, buffering.offset, size,
> "ISO-8859-1"); }  source.compact(); }
>
> Now you can simply "return" if you don't have enough data.
>
>
>
> On Mon, Sep 2, 2013 at 10:42 PM, Jon V.  wrote:
>
> >
> >
> >
> > On Mon, Sep 2, 2013 at 10:21 PM, Luciano Coelho
> wrote:
> >
> >> Yeah Jon, you're right about flush, the wrong thing is really the
> >> IoBuffer.
> >> I put the: session.getConfig().setReadBufferSize(16*1024), on
> >> connector as you told me.
> >>
> >> I changed now for what you answered me, like this:
> >>
> >> if(size > 0){
> >> while (buffer.hasRemaining()){
> >> byte[] payload = new byte[size];
> >>   buffer.get(payload);
> >>   data = new String( payload, "ISO-8859-1");
> >> }
> >> }
> >>
> >
> > Ok - Mina does not allow for compound rx_buffers.  This means you are
> > going to have to manually buffer the message yourself.
> >
> >
> > received( ByteBuffer source, IoSession session ) { while(
> > source.hasRemaining() ) {  ByteBuffer buffering =
> > session.getAttribute( SOME_PROPERTY_BUFFER_NAME );
> >
> > if( buffering != null )
> > {
> >// must be a new data
> >int size = // read size somehow
> >buffering = ByteBuffer.allocate( size );
> >
> >buffering.put(source);
> >
> >if( buffering.hasRemaining() )
> >{
> > session.setAttribute( SOME_PROPERTY_BUFFER_NAME, buffering );  return;
> >}
> >else
> >{
> >  // message is complete
> > session.clearAttribute( SOME_PROPERTY_BUFFER_NAME ); String data = new
> > String( buffering.array, buffering.offset, buffering.limit,
> > "ISO-8859-1");
> >}
> > }
> > else
> > {
> >  buffering.put(source);
> >  if( !buffering.hasRemaining() )
> >  {
> > // message is complete
> > session.clearAttribute( SOME_PROPERTY_BUFFER_NAME );  String data =
> > new String( buffering.array, buffering.offset, buffering.limit,
> > "ISO-8859-1"); }  else { return; }  } } }
> >
> > In MINA you have to read everything out of that ByteBuffer or it will
> > be lost forever.  This means you could get stuck only having 2 bytes
> > in the buffer and not enough to read the size value.  So you may have
> > to setup a secondary buffer to store partial size values if that scenario
> does occur.
> >
> >
> >>
> >> I'm receiving from de server 2685 bytes and I set the buffer to
> >> 64*1024, and I'm still having the error: D/WEB(26934):
> >> java.nio.BufferUnderflowException.
> >>
> >> I saw that setting tcpnodelay = false becomes better, I got make 3
> >> requests without error, but after the error happens again, and I have
> >> to restart the session again.
> >> Do I have to finish something in the IoBuffer after receive the data?
> >> Note that I'm not opening another session, I open one time and stay
> >> changing data all the time. The rest is functioning very well, one by
> >> one minute I send something and the server answe

Re: Send/Receive IoBuffer

2013-09-02 Thread Jon V.
Fix

if( buffering == null )
 {
buffering = ByteBuffer.allocate( some size );
session.setAtribute( SOME_PROPERTY_BUFFER_NAME, buffering );
 }


On Mon, Sep 2, 2013 at 10:54 PM, Jon V.  wrote:

> This is better:  I am not going to use the correct API but you can get the
> idea.
>
> Create a Filter called CompoundBufferFilter
>
> filter_received( ByteBuffer source, IoSession session, Filter next )
> {
>  ByteBuffer buffering = session.getAttribute( SOME_PROPERTY_BUFFER_NAME );
>
>  if( buffering == null )
>  {
> buffering = ByteBuffer.allocate( some size );
>  }
>
>  buffering.put( source );
>  buffering.flip();
>
>  next.received( buffering, session );
> }
>
> This will compound buffer incoming data.
>
> logic_received( ByteBuffer source, IoSession session )
> {
> while( source.hasRemaining() )
> {
>  source.mark();
> if( source.remaining < 4 )
> {
> source.reset();
> return;
> }
>  int size = source.getInt();
>  if( source.remaining < size )
>  {
> source.reset();
> return;
> }
>  String data = new String( buffering.array, buffering.offset, size,
>  "ISO-8859-1");
> }
>  source.compact();
> }
>
> Now you can simply "return" if you don't have enough data.
>
>
>
> On Mon, Sep 2, 2013 at 10:42 PM, Jon V.  wrote:
>
>>
>>
>>
>> On Mon, Sep 2, 2013 at 10:21 PM, Luciano Coelho 
>> wrote:
>>
>>> Yeah Jon, you're right about flush, the wrong thing is really the
>>> IoBuffer.
>>> I put the: session.getConfig().setReadBufferSize(16*1024), on connector
>>> as
>>> you told me.
>>>
>>> I changed now for what you answered me, like this:
>>>
>>> if(size > 0){
>>> while (buffer.hasRemaining()){
>>> byte[] payload = new byte[size];
>>>   buffer.get(payload);
>>>   data = new String( payload, "ISO-8859-1");
>>> }
>>> }
>>>
>>
>> Ok - Mina does not allow for compound rx_buffers.  This means you are
>> going to have to manually buffer the message yourself.
>>
>>
>> received( ByteBuffer source, IoSession session )
>> {
>> while( source.hasRemaining() )
>> {
>>  ByteBuffer buffering = session.getAttribute( SOME_PROPERTY_BUFFER_NAME );
>>
>> if( buffering != null )
>> {
>>// must be a new data
>>int size = // read size somehow
>>buffering = ByteBuffer.allocate( size );
>>
>>buffering.put(source);
>>
>>if( buffering.hasRemaining() )
>>{
>> session.setAttribute( SOME_PROPERTY_BUFFER_NAME, buffering );
>>  return;
>>}
>>else
>>{
>>  // message is complete
>> session.clearAttribute( SOME_PROPERTY_BUFFER_NAME );
>> String data = new String( buffering.array, buffering.offset,
>> buffering.limit,  "ISO-8859-1");
>>}
>> }
>> else
>> {
>>  buffering.put(source);
>>  if( !buffering.hasRemaining() )
>>  {
>> // message is complete
>> session.clearAttribute( SOME_PROPERTY_BUFFER_NAME );
>>  String data = new String( buffering.array, buffering.offset,
>> buffering.limit,  "ISO-8859-1");
>> }
>>  else
>> {
>> return;
>> }
>>  }
>> }
>> }
>>
>> In MINA you have to read everything out of that ByteBuffer or it will be
>> lost forever.  This means you could get stuck only having 2 bytes in the
>> buffer and not enough to read the size value.  So you may have to setup a
>> secondary buffer to store partial size values if that scenario does occur.
>>
>>
>>>
>>> I'm receiving from de server 2685 bytes and I set the buffer to 64*1024,
>>> and
>>> I'm still having the error: D/WEB(26934):
>>> java.nio.BufferUnderflowException.
>>>
>>> I saw that setting tcpnodelay = false becomes better, I got make 3
>>> requests
>>> without error, but after the error happens again, and I have to restart
>>> the
>>> session again.
>>> Do I have to finish something in the IoBuffer after receive the data?
>>> Note
>>> that I'm not opening another session, I open one time and stay changing
>>> data
>>> all the time. The rest is functioning very well, one by one minute I send
>>> something and the server answer quickly, the only problem now is this big
>>> request that one time goes another time not.
>>>
>>> Thank's again.
>>>

Re: Send/Receive IoBuffer

2013-09-02 Thread Jon V.
This is better:  I am not going to use the correct API but you can get the
idea.

Create a Filter called CompoundBufferFilter

filter_received( ByteBuffer source, IoSession session, Filter next )
{
 ByteBuffer buffering = session.getAttribute( SOME_PROPERTY_BUFFER_NAME );

 if( buffering == null )
 {
buffering = ByteBuffer.allocate( some size );
 }

 buffering.put( source );
 buffering.flip();

 next.received( buffering, session );
}

This will compound buffer incoming data.

logic_received( ByteBuffer source, IoSession session )
{
while( source.hasRemaining() )
{
source.mark();
if( source.remaining < 4 )
{
source.reset();
return;
}
 int size = source.getInt();
 if( source.remaining < size )
{
source.reset();
return;
}
 String data = new String( buffering.array, buffering.offset, size,
 "ISO-8859-1");
}
 source.compact();
}

Now you can simply "return" if you don't have enough data.



On Mon, Sep 2, 2013 at 10:42 PM, Jon V.  wrote:

>
>
>
> On Mon, Sep 2, 2013 at 10:21 PM, Luciano Coelho 
> wrote:
>
>> Yeah Jon, you're right about flush, the wrong thing is really the
>> IoBuffer.
>> I put the: session.getConfig().setReadBufferSize(16*1024), on connector as
>> you told me.
>>
>> I changed now for what you answered me, like this:
>>
>> if(size > 0){
>> while (buffer.hasRemaining()){
>> byte[] payload = new byte[size];
>>   buffer.get(payload);
>>   data = new String( payload, "ISO-8859-1");
>> }
>> }
>>
>
> Ok - Mina does not allow for compound rx_buffers.  This means you are
> going to have to manually buffer the message yourself.
>
>
> received( ByteBuffer source, IoSession session )
> {
> while( source.hasRemaining() )
> {
>  ByteBuffer buffering = session.getAttribute( SOME_PROPERTY_BUFFER_NAME );
>
> if( buffering != null )
> {
>// must be a new data
>int size = // read size somehow
>buffering = ByteBuffer.allocate( size );
>
>buffering.put(source);
>
>if( buffering.hasRemaining() )
>{
> session.setAttribute( SOME_PROPERTY_BUFFER_NAME, buffering );
>  return;
>}
>else
>{
>  // message is complete
> session.clearAttribute( SOME_PROPERTY_BUFFER_NAME );
> String data = new String( buffering.array, buffering.offset,
> buffering.limit,  "ISO-8859-1");
>}
> }
> else
> {
>  buffering.put(source);
>  if( !buffering.hasRemaining() )
>  {
> // message is complete
> session.clearAttribute( SOME_PROPERTY_BUFFER_NAME );
>  String data = new String( buffering.array, buffering.offset,
> buffering.limit,  "ISO-8859-1");
> }
>  else
> {
> return;
> }
>  }
> }
> }
>
> In MINA you have to read everything out of that ByteBuffer or it will be
> lost forever.  This means you could get stuck only having 2 bytes in the
> buffer and not enough to read the size value.  So you may have to setup a
> secondary buffer to store partial size values if that scenario does occur.
>
>
>>
>> I'm receiving from de server 2685 bytes and I set the buffer to 64*1024,
>> and
>> I'm still having the error: D/WEB(26934):
>> java.nio.BufferUnderflowException.
>>
>> I saw that setting tcpnodelay = false becomes better, I got make 3
>> requests
>> without error, but after the error happens again, and I have to restart
>> the
>> session again.
>> Do I have to finish something in the IoBuffer after receive the data? Note
>> that I'm not opening another session, I open one time and stay changing
>> data
>> all the time. The rest is functioning very well, one by one minute I send
>> something and the server answer quickly, the only problem now is this big
>> request that one time goes another time not.
>>
>> Thank's again.
>>
>> LUCIANO
>>
>> -Mensagem original-
>> De: Jon V. [mailto:sybersn...@gmail.com]
>> Enviada em: segunda-feira, 2 de setembro de 2013 19:26
>> Para: users@mina.apache.org
>> Assunto: Re: Send/Receive IoBuffer
>>
>> On Mon, Sep 2, 2013 at 5:37 PM, Luciano Coelho
>> wrote:
>>
>> > Hello everybody.
>> >
>> >
>> >
>> > I'm learning how to use Mina and my questions are:
>> >
>> >
>> >
>> > I solved my problem of having a answer from my server without closing
>> > the session like this:
>> >
>> >
>> >
>> > System.out.flush();
>> >
>>
>>
>> This really gives me an indication of your Java knowledge.  System.out 

Re: Send/Receive IoBuffer

2013-09-02 Thread Jon V.
On Mon, Sep 2, 2013 at 10:21 PM, Luciano Coelho wrote:

> Yeah Jon, you're right about flush, the wrong thing is really the IoBuffer.
> I put the: session.getConfig().setReadBufferSize(16*1024), on connector as
> you told me.
>
> I changed now for what you answered me, like this:
>
> if(size > 0){
> while (buffer.hasRemaining()){
> byte[] payload = new byte[size];
>   buffer.get(payload);
>   data = new String( payload, "ISO-8859-1");
> }
> }
>

Ok - Mina does not allow for compound rx_buffers.  This means you are going
to have to manually buffer the message yourself.


received( ByteBuffer source, IoSession session )
{
while( source.hasRemaining() )
{
 ByteBuffer buffering = session.getAttribute( SOME_PROPERTY_BUFFER_NAME );

if( buffering != null )
{
   // must be a new data
   int size = // read size somehow
   buffering = ByteBuffer.allocate( size );

   buffering.put(source);

   if( buffering.hasRemaining() )
   {
session.setAttribute( SOME_PROPERTY_BUFFER_NAME, buffering );
 return;
   }
   else
   {
// message is complete
session.clearAttribute( SOME_PROPERTY_BUFFER_NAME );
String data = new String( buffering.array, buffering.offset,
buffering.limit,  "ISO-8859-1");
   }
}
else
{
buffering.put(source);
 if( !buffering.hasRemaining() )
{
// message is complete
session.clearAttribute( SOME_PROPERTY_BUFFER_NAME );
String data = new String( buffering.array, buffering.offset,
buffering.limit,  "ISO-8859-1");
}
else
{
return;
}
}
}
}

In MINA you have to read everything out of that ByteBuffer or it will be
lost forever.  This means you could get stuck only having 2 bytes in the
buffer and not enough to read the size value.  So you may have to setup a
secondary buffer to store partial size values if that scenario does occur.


>
> I'm receiving from de server 2685 bytes and I set the buffer to 64*1024,
> and
> I'm still having the error: D/WEB(26934):
> java.nio.BufferUnderflowException.
>
> I saw that setting tcpnodelay = false becomes better, I got make 3 requests
> without error, but after the error happens again, and I have to restart the
> session again.
> Do I have to finish something in the IoBuffer after receive the data? Note
> that I'm not opening another session, I open one time and stay changing
> data
> all the time. The rest is functioning very well, one by one minute I send
> something and the server answer quickly, the only problem now is this big
> request that one time goes another time not.
>
> Thank's again.
>
> LUCIANO
>
> -Mensagem original-
> De: Jon V. [mailto:sybersn...@gmail.com]
> Enviada em: segunda-feira, 2 de setembro de 2013 19:26
> Para: users@mina.apache.org
> Assunto: Re: Send/Receive IoBuffer
>
> On Mon, Sep 2, 2013 at 5:37 PM, Luciano Coelho
> wrote:
>
> > Hello everybody.
> >
> >
> >
> > I'm learning how to use Mina and my questions are:
> >
> >
> >
> > I solved my problem of having a answer from my server without closing
> > the session like this:
> >
> >
> >
> > System.out.flush();
> >
>
>
> This really gives me an indication of your Java knowledge.  System.out is
> your access to stdout in Java.  It is what you use to print things to the
> console.  It has nothing to do with your application.
>
> Maybe posting on StackOverflow would be a good idea for general java help?
>
>
> >
> >
> >
> > Is that ok?
> >
> >
> >
> > I'm receiving the answer in Android via GPRS like this:
> >
> >
> >
> > First I set this on sessionCreated
> >
> > session.getConfig().setReadBufferSize(16*1024);
> >
> >
> >
> You should set this in Mina config.  It is not good to change on the fly
> like this.
>
> Read the Quick Start Guide:
> http://mina.apache.org/mina-project/quick-start-guide.html
>
>
> >
> > @Override public void messageReceived(IoSession session, Object
> > message) throws Exception {
> >
> > IoBuffer  buffer
> > = (IoBuffer)   message;
> >
> > int  service
> > = (Integer) session.getAttribute("SERVICE");
> >
> > Listener   listener
> > = (Listener)session.getAttribute("LISTENER");
> >
> > String   data
> > = "";
> >
> > int  size
> > = 

Re: Send/Receive IoBuffer

2013-09-02 Thread Jon V.
On Mon, Sep 2, 2013 at 5:37 PM, Luciano Coelho wrote:

> Hello everybody.
>
>
>
> I'm learning how to use Mina and my questions are:
>
>
>
> I solved my problem of having a answer from my server without closing the
> session like this:
>
>
>
> System.out.flush();
>


This really gives me an indication of your Java knowledge.  System.out is
your access to stdout in Java.  It is what you use to print things to the
console.  It has nothing to do with your application.

Maybe posting on StackOverflow would be a good idea for general java help?


>
>
>
> Is that ok?
>
>
>
> I'm receiving the answer in Android via GPRS like this:
>
>
>
> First I set this on sessionCreated
>
> session.getConfig().setReadBufferSize(16*1024);
>
>
>
You should set this in Mina config.  It is not good to change on the fly
like this.

Read the Quick Start Guide:
http://mina.apache.org/mina-project/quick-start-guide.html


>
> @Override public void messageReceived(IoSession session, Object message)
> throws Exception {
>
> IoBuffer  buffer
> = (IoBuffer)   message;
>
> int  service
> = (Integer) session.getAttribute("SERVICE");
>
> Listener   listener
> = (Listener)session.getAttribute("LISTENER");
>
> String   data
> = "";
>
> int  size
> = buffer.getInt();
>
> while (buffer.hasRemaining()){
>
>data += (char) buffer.get();
>

Using the += is the worst possible way to build a String.

Since you are reading a String.  Are you sure that the String is encoded
using 8 bits?

byte[] payload = new byte[size];
buffer.get(payload);

String data = new String( payload, "UTF-8");



>
> }
>
> if(size == data.trim().length()){
>

Why are you trying to trim the string?  Are you expecting whitespaces?


>
>if(listener != null)
> listener.requisitionFinished(data, service);
>
> } else {
>
>if(listener != null)
> listener.requisitionFinished("", service);
>
> }
>
> Log.d("WEB", "SERVICE: " + service + " SIZE: " + size + "
> DATA: " + data);
>
> }
>
>
>
> Sometimes I receive the data in parts, when the message arriving is too
> long
> and it causes an error, even if the buffersize is bigger than the data I'm
> receiving.
>
>
>
> Thank's a lot.
>
>
>
> Luciano Coelho
>
>


Re: Regarding DIRMINA-912

2013-08-25 Thread Jon V.
Sounds like you need a task queue and a single dispatcher thread. Write the
metered messages to the task queue and let it do the temporal management.
This can all be done with one thread.
On Aug 25, 2013 11:57 AM, "Mike McKnight"  wrote:

> In my case I have units on the ground that need to have messages throttled
> when being sent to the units. In other words all of the queued write events
> going to each unit need to be metered out in an temporal fashion.  I have a
> separate thread pool available that can expand to the number of units on
> the ground, which is max around 50, and handles this metering process.
>  Message processing for all but WRITE events needs to be unfettered in any
> way and can not be held up for writes being throttled.  So for sure I need
> another executor filter that handles all but WRITE events.
>
> I don't see how I can do this with a single executor filter. As events are
> processed in order in a queue and if I am waiting on a write then
> MESSAGE_RECEIVED events are not going to get processed. There are no
> separate SessionTasksQueue for the OrderedThreadPoolExecutor, just the one
> for all events waiting to be processed.
>
> Filter chain looks like this:
>  * codec
>  * inbound-filter (executor filter for all but WRITE events)
>  * write-throttle-filter (overrides filterWrite)
>  * outbound-filter (executor filter for WRITE events only)
> On 08/23/2013 12:32 PM, Jon V. wrote:
>
>> What is the use case for having different thread pools for read and write
>> events?
>>
>> Writes are already scheduled one they hit the worker. Not like your write
>> process is going to slow down an already threaded read request.
>> On Aug 22, 2013 5:52 PM, "Mike McKnight"  wrote:
>>
>>  I am just curious if there is a downside to this issue that I am not
>>> seeing.  I have seen this in my MINA application; I have inbound/outbound
>>> executor filters as described in the issue and have seen where my inbound
>>> threads are *sometimes* processing IoEventType.WRITE events.  I don't see
>>> any adverse effects of this, my messages are being put on the wire, but
>>> am
>>> checking in with the list to be sure.
>>>
>>> I am running mina-2.0.7.
>>>
>>> https://issues.apache.org/jira/browse/DIRMINA-912<https://issues.apache.org/**jira/browse/DIRMINA-912>
>>> https://issues.apache.org/jira/browse/DIRMINA-912>
>>> >
>>>
>>> Thanks!
>>>
>>> Mike
>>>
>>>
>


Re: Regarding DIRMINA-912

2013-08-23 Thread Jon V.
What is the use case for having different thread pools for read and write
events?

Writes are already scheduled one they hit the worker. Not like your write
process is going to slow down an already threaded read request.
On Aug 22, 2013 5:52 PM, "Mike McKnight"  wrote:

> I am just curious if there is a downside to this issue that I am not
> seeing.  I have seen this in my MINA application; I have inbound/outbound
> executor filters as described in the issue and have seen where my inbound
> threads are *sometimes* processing IoEventType.WRITE events.  I don't see
> any adverse effects of this, my messages are being put on the wire, but am
> checking in with the list to be sure.
>
> I am running mina-2.0.7.
>
> https://issues.apache.org/**jira/browse/DIRMINA-912
>
> Thanks!
>
> Mike
>


Re: AW: AW: NioSocketConnector/NioSocketAcceptor

2013-08-15 Thread Jon V.
Please don't take this the wrong way. The apache Mina site is full of
examples and documentation. That should be your primary source of
information before asking questions on the email list.

Remember, this list covers 5 different projects and your email goes out to
a lot of people.

I am very happy to answer questions that involve things that are not
covered by the docs.
On Aug 15, 2013 11:31 AM, "Emmanuel Lécharny"  wrote:

> Le 8/15/13 5:13 PM, Simo Chiegang, Boris Arthur RD-P8.1 a écrit :
> > Ok that  means, when  I write new NioSocketConnector(), the number of
> threads to use isn't no limited. If I give a a processorCount (may be 2 ),
> I will limit the number of threads to 2. I'm wright?
>
> Yes.
>
> If you don't provide any value, the number of IoProcessor will be Nb
> Core + 1.
>
> usually, it's enough. If you need more, you can add an executor in the
> filter chain, and use a Pool. But keep in mind that whatever you do, if
> you are CPU bound, no matter how many threads you add, you are not going
> to have better throughput.
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>


Re: Creating a new instance of an IoHandler for each connection?

2013-08-08 Thread Jon
This is against the design. 

You could add this into the source pretty easy and build a custom version of 
Mina. 

Sent from my iPhone

On Aug 8, 2013, at 12:36 AM, Nick_  wrote:

> I can't seem to find a way to allow each connection to have it's own handler
> 
> 
> 
> --
> View this message in context: 
> http://apache-mina.10907.n7.nabble.com/Creating-a-new-instance-of-an-IoHandler-for-each-connection-tp39443.html
> Sent from the Apache MINA User Forum mailing list archive at Nabble.com.


Re: User authentication

2013-08-07 Thread Jon V.
There really shouldn't be anything in created and opened unless you are
going to authenticate based on an IP address.

The authentication should be a part of your command message structure.

So you parse the commands into objects. Then you pass to the authentication
filter.

If message is of type authentication then do authentication else if
authenticated pass to the handler. If not authenticated and not type
authentication then close the session.

You only have two states. Authenticated or not.
On Aug 7, 2013 3:37 PM, "Hunter McMillen"  wrote:

> so all of the logic for the handler will basically be in messageReceived?
> And the state machine manages sessionCreated()/**sessionOpened()?
>
>
> Hunter
> On 8/7/2013 3:29 PM, Jon V. wrote:
>
>> That is basically how it is done.
>>
>> Io->packet processor->state machine->handler
>>
>> The state machine should only handle one packet at a time.
>>
>> In the message received just do...
>>
>> If ( authenticated )
>> Next filter.message received( msg )
>>
>> Else
>>
>> Etc
>> On Aug 7, 2013 3:22 PM, "Hunter McMillen"  wrote:
>>
>>  So that is actually the solution we had before, but the state machine was
>>> in an authentication filter, we had a lot of trouble transitioning from
>>> "ok
>>> now I am done authenticating, I want to be in my IoHandler now"
>>>
>>> Hunter
>>> On 8/7/2013 3:03 PM, Jon wrote:
>>>
>>>  So just implement some sort if authentication using the state machine
>>>> and
>>>> a database record lookup.
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On Aug 7, 2013, at 2:11 PM, Hunter McMillen  wrote:
>>>>
>>>>   I misunderstood what you were asking, yes we have an abstract Command
>>>>
>>>>> class that has derivatives for all of the commands that a user could
>>>>> enter.
>>>>>
>>>>> Hunter
>>>>> On 8/7/2013 1:13 PM, Jon wrote:
>>>>>
>>>>>  You must be building some sort of communication format for it.
>>>>>>
>>>>>> Sent from my iPhone
>>>>>>
>>>>>> On Aug 7, 2013, at 1:06 PM, Hunter McMillen 
>>>>>> wrote:
>>>>>>
>>>>>>   We're not really implementing a protocol, we are just trying to
>>>>>> make a
>>>>>>
>>>>>>> text-based game that will seamlessly support hundreds to thousands
>>>>>>> of users
>>>>>>> at a time.
>>>>>>>
>>>>>>> Hunter
>>>>>>> On 8/7/2013 12:02 PM, Jon wrote:
>>>>>>>
>>>>>>>  This is more of a protocol implementation than a networking
>>>>>>>> question.
>>>>>>>>   What kind of protocol are you implementing.
>>>>>>>>
>>>>>>>> Sent from my iPhone
>>>>>>>>
>>>>>>>> On Aug 7, 2013, at 11:34 AM, Hunter McMillen 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>   We actually won't need anything as complex as LDAP, just a simple
>>>>>>>> DB
>>>>>>>>
>>>>>>>>> hash + salt lookup.
>>>>>>>>>
>>>>>>>>> Hunter
>>>>>>>>> On 8/7/2013 10:26 AM, Emmanuel Lécharny wrote:
>>>>>>>>>
>>>>>>>>>  Le 8/7/13 4:11 PM, Hunter McMillen a écrit :
>>>>>>>>>>
>>>>>>>>>>  What are the common ways to authenticate users using Mina?
>>>>>>>>>>>
>>>>>>>>>>> The first attempt I made was using a state machine, but I had
>>>>>>>>>>> problems
>>>>>>>>>>> integrating that with an IoHandler.
>>>>>>>>>>>
>>>>>>>>>>> In retrospect, the state machine seems like overkill; so I was
>>>>>>>>>>> hoping
>>>>>>>>>>> to get ideas for other ways to authenticate users, or maybe a
>>>>>>>>>>> link
>>>>>>>>>>> to
>>>>>>>>>>> an application that does some authentication.
>>>>>>>>>>>
>>>>>>>>>>> would it be terrible to do something like this?
>>>>>>>>>>>
>>>>>>>>>>> public void sessionCreated(IoSession session) {
>>>>>>>>>>>   authenticateUser()  // < - Good idea? Bad Idea? Run in
>>>>>>>>>>> a
>>>>>>>>>>> separate thread?
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>>  Depends...
>>>>>>>>>>
>>>>>>>>>> let's see how it works with LDAP :
>>>>>>>>>>
>>>>>>>>>> - the user can connect on the server (and the sessionCreated event
>>>>>>>>>> is
>>>>>>>>>> handled), but the user will not be authentified at this point.
>>>>>>>>>>
>>>>>>>>>> - in order to authenticate the user, we need to know about the
>>>>>>>>>> user.
>>>>>>>>>> Just having his IP address is certainly not good enough (it's easy
>>>>>>>>>> to
>>>>>>>>>> spoof it), so we expect the client to sent some credentials in the
>>>>>>>>>> first
>>>>>>>>>> dedicated message. In LDAP this is done through a BindRequest.
>>>>>>>>>> Anyway,
>>>>>>>>>> as you require the user to send you some data, you have to process
>>>>>>>>>> them
>>>>>>>>>> by handling the messageReceived event.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Last, not least : what about a separate thread ?
>>>>>>>>>>
>>>>>>>>>> That's a good question. The answer, again is "it depends". If it
>>>>>>>>>> takes
>>>>>>>>>> seconds to authenticat a user, because you have to send the auth
>>>>>>>>>> request
>>>>>>>>>> to a remote server, then having a separate thread for that sounds
>>>>>>>>>> smart.
>>>>>>>>>> Most of the time, the authent will take a few ms, and will be done
>>>>>>>>>> quite
>>>>>>>>>> rarely, so it's enough to execute this code in the same thread.
>>>>>>>>>>
>>>>>>>>>> Hope it helps.
>>>>>>>>>>
>>>>>>>>>>
>


Re: User authentication

2013-08-07 Thread Jon V.
That is basically how it is done.

Io->packet processor->state machine->handler

The state machine should only handle one packet at a time.

In the message received just do...

If ( authenticated )
Next filter.message received( msg )

Else

Etc
On Aug 7, 2013 3:22 PM, "Hunter McMillen"  wrote:

> So that is actually the solution we had before, but the state machine was
> in an authentication filter, we had a lot of trouble transitioning from "ok
> now I am done authenticating, I want to be in my IoHandler now"
>
> Hunter
> On 8/7/2013 3:03 PM, Jon wrote:
>
>> So just implement some sort if authentication using the state machine and
>> a database record lookup.
>>
>> Sent from my iPhone
>>
>> On Aug 7, 2013, at 2:11 PM, Hunter McMillen  wrote:
>>
>>  I misunderstood what you were asking, yes we have an abstract Command
>>> class that has derivatives for all of the commands that a user could enter.
>>>
>>> Hunter
>>> On 8/7/2013 1:13 PM, Jon wrote:
>>>
>>>> You must be building some sort of communication format for it.
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On Aug 7, 2013, at 1:06 PM, Hunter McMillen  wrote:
>>>>
>>>>  We're not really implementing a protocol, we are just trying to make a
>>>>> text-based game that will seamlessly support hundreds to thousands of 
>>>>> users
>>>>> at a time.
>>>>>
>>>>> Hunter
>>>>> On 8/7/2013 12:02 PM, Jon wrote:
>>>>>
>>>>>> This is more of a protocol implementation than a networking question.
>>>>>>  What kind of protocol are you implementing.
>>>>>>
>>>>>> Sent from my iPhone
>>>>>>
>>>>>> On Aug 7, 2013, at 11:34 AM, Hunter McMillen 
>>>>>> wrote:
>>>>>>
>>>>>>  We actually won't need anything as complex as LDAP, just a simple DB
>>>>>>> hash + salt lookup.
>>>>>>>
>>>>>>> Hunter
>>>>>>> On 8/7/2013 10:26 AM, Emmanuel Lécharny wrote:
>>>>>>>
>>>>>>>> Le 8/7/13 4:11 PM, Hunter McMillen a écrit :
>>>>>>>>
>>>>>>>>> What are the common ways to authenticate users using Mina?
>>>>>>>>>
>>>>>>>>> The first attempt I made was using a state machine, but I had
>>>>>>>>> problems
>>>>>>>>> integrating that with an IoHandler.
>>>>>>>>>
>>>>>>>>> In retrospect, the state machine seems like overkill; so I was
>>>>>>>>> hoping
>>>>>>>>> to get ideas for other ways to authenticate users, or maybe a link
>>>>>>>>> to
>>>>>>>>> an application that does some authentication.
>>>>>>>>>
>>>>>>>>> would it be terrible to do something like this?
>>>>>>>>>
>>>>>>>>> public void sessionCreated(IoSession session) {
>>>>>>>>>  authenticateUser()  // < - Good idea? Bad Idea? Run in a
>>>>>>>>> separate thread?
>>>>>>>>> }
>>>>>>>>>
>>>>>>>> Depends...
>>>>>>>>
>>>>>>>> let's see how it works with LDAP :
>>>>>>>>
>>>>>>>> - the user can connect on the server (and the sessionCreated event
>>>>>>>> is
>>>>>>>> handled), but the user will not be authentified at this point.
>>>>>>>>
>>>>>>>> - in order to authenticate the user, we need to know about the user.
>>>>>>>> Just having his IP address is certainly not good enough (it's easy
>>>>>>>> to
>>>>>>>> spoof it), so we expect the client to sent some credentials in the
>>>>>>>> first
>>>>>>>> dedicated message. In LDAP this is done through a BindRequest.
>>>>>>>> Anyway,
>>>>>>>> as you require the user to send you some data, you have to process
>>>>>>>> them
>>>>>>>> by handling the messageReceived event.
>>>>>>>>
>>>>>>>>
>>>>>>>> Last, not least : what about a separate thread ?
>>>>>>>>
>>>>>>>> That's a good question. The answer, again is "it depends". If it
>>>>>>>> takes
>>>>>>>> seconds to authenticat a user, because you have to send the auth
>>>>>>>> request
>>>>>>>> to a remote server, then having a separate thread for that sounds
>>>>>>>> smart.
>>>>>>>> Most of the time, the authent will take a few ms, and will be done
>>>>>>>> quite
>>>>>>>> rarely, so it's enough to execute this code in the same thread.
>>>>>>>>
>>>>>>>> Hope it helps.
>>>>>>>>
>>>>>>>
>


Re: User authentication

2013-08-07 Thread Jon
So just implement some sort if authentication using the state machine and a 
database record lookup. 

Sent from my iPhone

On Aug 7, 2013, at 2:11 PM, Hunter McMillen  wrote:

> I misunderstood what you were asking, yes we have an abstract Command class 
> that has derivatives for all of the commands that a user could enter.
> 
> Hunter
> On 8/7/2013 1:13 PM, Jon wrote:
>> You must be building some sort of communication format for it.
>> 
>> Sent from my iPhone
>> 
>> On Aug 7, 2013, at 1:06 PM, Hunter McMillen  wrote:
>> 
>>> We're not really implementing a protocol, we are just trying to make a 
>>> text-based game that will seamlessly support hundreds to thousands of users 
>>> at a time.
>>> 
>>> Hunter
>>> On 8/7/2013 12:02 PM, Jon wrote:
>>>> This is more of a protocol implementation than a networking question.  
>>>> What kind of protocol are you implementing.
>>>> 
>>>> Sent from my iPhone
>>>> 
>>>> On Aug 7, 2013, at 11:34 AM, Hunter McMillen  wrote:
>>>> 
>>>>> We actually won't need anything as complex as LDAP, just a simple DB hash 
>>>>> + salt lookup.
>>>>> 
>>>>> Hunter
>>>>> On 8/7/2013 10:26 AM, Emmanuel Lécharny wrote:
>>>>>> Le 8/7/13 4:11 PM, Hunter McMillen a écrit :
>>>>>>> What are the common ways to authenticate users using Mina?
>>>>>>> 
>>>>>>> The first attempt I made was using a state machine, but I had problems
>>>>>>> integrating that with an IoHandler.
>>>>>>> 
>>>>>>> In retrospect, the state machine seems like overkill; so I was hoping
>>>>>>> to get ideas for other ways to authenticate users, or maybe a link to
>>>>>>> an application that does some authentication.
>>>>>>> 
>>>>>>> would it be terrible to do something like this?
>>>>>>> 
>>>>>>> public void sessionCreated(IoSession session) {
>>>>>>> authenticateUser()  // < - Good idea? Bad Idea? Run in a
>>>>>>> separate thread?
>>>>>>> }
>>>>>> Depends...
>>>>>> 
>>>>>> let's see how it works with LDAP :
>>>>>> 
>>>>>> - the user can connect on the server (and the sessionCreated event is
>>>>>> handled), but the user will not be authentified at this point.
>>>>>> 
>>>>>> - in order to authenticate the user, we need to know about the user.
>>>>>> Just having his IP address is certainly not good enough (it's easy to
>>>>>> spoof it), so we expect the client to sent some credentials in the first
>>>>>> dedicated message. In LDAP this is done through a BindRequest. Anyway,
>>>>>> as you require the user to send you some data, you have to process them
>>>>>> by handling the messageReceived event.
>>>>>> 
>>>>>> 
>>>>>> Last, not least : what about a separate thread ?
>>>>>> 
>>>>>> That's a good question. The answer, again is "it depends". If it takes
>>>>>> seconds to authenticat a user, because you have to send the auth request
>>>>>> to a remote server, then having a separate thread for that sounds smart.
>>>>>> Most of the time, the authent will take a few ms, and will be done quite
>>>>>> rarely, so it's enough to execute this code in the same thread.
>>>>>> 
>>>>>> Hope it helps.
> 


Re: User authentication

2013-08-07 Thread Jon
You must be building some sort of communication format for it.

Sent from my iPhone

On Aug 7, 2013, at 1:06 PM, Hunter McMillen  wrote:

> We're not really implementing a protocol, we are just trying to make a 
> text-based game that will seamlessly support hundreds to thousands of users 
> at a time.
> 
> Hunter
> On 8/7/2013 12:02 PM, Jon wrote:
>> This is more of a protocol implementation than a networking question.  What 
>> kind of protocol are you implementing.
>> 
>> Sent from my iPhone
>> 
>> On Aug 7, 2013, at 11:34 AM, Hunter McMillen  wrote:
>> 
>>> We actually won't need anything as complex as LDAP, just a simple DB hash + 
>>> salt lookup.
>>> 
>>> Hunter
>>> On 8/7/2013 10:26 AM, Emmanuel Lécharny wrote:
>>>> Le 8/7/13 4:11 PM, Hunter McMillen a écrit :
>>>>> What are the common ways to authenticate users using Mina?
>>>>> 
>>>>> The first attempt I made was using a state machine, but I had problems
>>>>> integrating that with an IoHandler.
>>>>> 
>>>>> In retrospect, the state machine seems like overkill; so I was hoping
>>>>> to get ideas for other ways to authenticate users, or maybe a link to
>>>>> an application that does some authentication.
>>>>> 
>>>>> would it be terrible to do something like this?
>>>>> 
>>>>> public void sessionCreated(IoSession session) {
>>>>> authenticateUser()  // < - Good idea? Bad Idea? Run in a
>>>>> separate thread?
>>>>> }
>>>> Depends...
>>>> 
>>>> let's see how it works with LDAP :
>>>> 
>>>> - the user can connect on the server (and the sessionCreated event is
>>>> handled), but the user will not be authentified at this point.
>>>> 
>>>> - in order to authenticate the user, we need to know about the user.
>>>> Just having his IP address is certainly not good enough (it's easy to
>>>> spoof it), so we expect the client to sent some credentials in the first
>>>> dedicated message. In LDAP this is done through a BindRequest. Anyway,
>>>> as you require the user to send you some data, you have to process them
>>>> by handling the messageReceived event.
>>>> 
>>>> 
>>>> Last, not least : what about a separate thread ?
>>>> 
>>>> That's a good question. The answer, again is "it depends". If it takes
>>>> seconds to authenticat a user, because you have to send the auth request
>>>> to a remote server, then having a separate thread for that sounds smart.
>>>> Most of the time, the authent will take a few ms, and will be done quite
>>>> rarely, so it's enough to execute this code in the same thread.
>>>> 
>>>> Hope it helps.
> 


Re: User authentication

2013-08-07 Thread Jon
This is more of a protocol implementation than a networking question.  What 
kind of protocol are you implementing. 

Sent from my iPhone

On Aug 7, 2013, at 11:34 AM, Hunter McMillen  wrote:

> We actually won't need anything as complex as LDAP, just a simple DB hash + 
> salt lookup.
> 
> Hunter
> On 8/7/2013 10:26 AM, Emmanuel Lécharny wrote:
>> Le 8/7/13 4:11 PM, Hunter McMillen a écrit :
>>> What are the common ways to authenticate users using Mina?
>>> 
>>> The first attempt I made was using a state machine, but I had problems
>>> integrating that with an IoHandler.
>>> 
>>> In retrospect, the state machine seems like overkill; so I was hoping
>>> to get ideas for other ways to authenticate users, or maybe a link to
>>> an application that does some authentication.
>>> 
>>> would it be terrible to do something like this?
>>> 
>>> public void sessionCreated(IoSession session) {
>>> authenticateUser()  // < - Good idea? Bad Idea? Run in a
>>> separate thread?
>>> }
>> Depends...
>> 
>> let's see how it works with LDAP :
>> 
>> - the user can connect on the server (and the sessionCreated event is
>> handled), but the user will not be authentified at this point.
>> 
>> - in order to authenticate the user, we need to know about the user.
>> Just having his IP address is certainly not good enough (it's easy to
>> spoof it), so we expect the client to sent some credentials in the first
>> dedicated message. In LDAP this is done through a BindRequest. Anyway,
>> as you require the user to send you some data, you have to process them
>> by handling the messageReceived event.
>> 
>> 
>> Last, not least : what about a separate thread ?
>> 
>> That's a good question. The answer, again is "it depends". If it takes
>> seconds to authenticat a user, because you have to send the auth request
>> to a remote server, then having a separate thread for that sounds smart.
>> Most of the time, the authent will take a few ms, and will be done quite
>> rarely, so it's enough to execute this code in the same thread.
>> 
>> Hope it helps.
> 


Re: Using an Authentication Filter and IoHandlerAdapter

2013-08-02 Thread Jon V.
The major problem with any kind of ordering is the blocking and major
performance problems relative to the load.
On Aug 1, 2013 9:55 PM, "Ashish"  wrote:

> On Fri, Aug 2, 2013 at 7:15 AM, Jon V.  wrote:
>
> > To my knowledge the executor filter does not guarantee any kind of order.
> > This means that you should implement the authentication phase before the
> > executor.
> >
>
> This is correct, with Executor filter ordering is not guaranteed. Do you
> need an executor filter there?
> It's usage is recommended if you have some intensive task in chain or in
> IoHandler.
>
>
> >
> > Io->prorocol->authentication->executor->handler
> >
>
> This sound good. Alternative is to use OrderedThreadPoolExecutor, but go
> simple first.
> Implement stuff without Executor filter and then push that in if needed.
>
>
> >
> > You cannot lock on out of order messaging without a queue and attempt to
> > re-order the messages.
> > On Aug 1, 2013 9:33 PM, "Hunter McMillen"  wrote:
> >
> > > Sorry, the code is probably more useful to see, here is the entry point
> > > to our application:
> > >
> > > acceptor = new NioSocketAcceptor(
> > > Runtime.getRuntime().availableProcessors() );
> > > acceptor.getFilterChain().addLast("executor", new
> > > ExecutorFilter( Executors.newCachedThreadPool()));
> > > acceptor.getFilterChain().addLast("logger",
> > > MudConfig.Logging.getFilter());
> > > acceptor.getFilterChain().addLast("codec",
> > > new ProtocolCodecFilter(
> > > new TextLineEncoder(), new CommandDecoder()
> > > )
> > > );
> > >
> > > More importantly, my main question is how I can link the DONE state of
> > > the state machine (AuthenticationHandler) and the IoHandlerAdapter. I
> > > can post the code for these also, I just didn't want to overload the
> > > thread.
> > >
> > > Thanks.
> > > Hunter
> > > On 8/1/13 5:47 PM, Jon wrote:
> > > > You are not using an executor filter right? You have to implement
> > > locking during the authentication phase if you are using thread
> > scheduling.
> > > >
> > > > Sent from my iPhone
> > > >
> > > > On Aug 1, 2013, at 5:31 PM, Hunter McMillen 
> > wrote:
> > > >
> > > >> Hello,
> > > >>
> > > >> I recently started working on a project with a friend that is a
> > > text-based game. We were having trouble with ReadFuture's when trying
> to
> > > get a username/password combination from the user so we decided to
> follow
> > > the state machine example from Tapedeck TCP server on Mina's homepage:
> > >
> >
> http://mina.apache.org/mina-project/xref/org/apache/mina/example/tapedeck/
> > > >>
> > > >> I have gotten the state machine to a point where it seems to be
> > working
> > > well. It starts, reads a username, then a password, then has some logic
> > to
> > > restart based on error; or it prints a message 'Authenticated'.
> > > >>
> > > >> However our main application logic is going to be (our plan at
> least)
> > > held in an IoHandlerAdapter, my question is what is a good way to
> > integrate
> > > the two of these:
> > > >>
> > > >> 1) The state machine authentication filter from the example above
> > > >> 2) An IoHandlerAdapter that will track information about connected
> > > users and sessions
> > > >>
> > > >> My confusion mainly lies in how to transition between the state
> > machine
> > > and the IoHandlerAdapter since they both respond to /sessionCreated
> /and
> > > /sessionOpened /events.
> > > >>
> > > >> Any help, ideas, or input would be appreciated.
> > > >>
> > > >> Thanks.
> > > >> Hunter
> > >
> > >
> >
>
>
>
> --
> thanks
> ashish
>
> Blog: http://www.ashishpaliwal.com/blog
> My Photo Galleries: http://www.pbase.com/ashishpaliwal
>


Re: Using an Authentication Filter and IoHandlerAdapter

2013-08-02 Thread Jon V.
Write your state to the IoSession and read it from the handler.
On Aug 1, 2013 10:06 PM, "Hunter McMillen"  wrote:

> Ok I think I understand the ordering now, we probably don't need an
> Executor. Our main issue is still how to link the state machine with our
> IoHandlerAdaptor.
>
> As of right now, after a user is authenticated (by the statemachine),
> the sessionIdle() event of the statemachine calls sessionOpened of our
> IoHandlerAdapter; obviously this is a logic error because sessionIdle()
> will fire frequently.
>
> So two things:
> 1) Is there a way to leave the statemachine after we authenticate someone?
> 2) If not, how to map the finishing of authentication to our
> IoHandlerAdapter ,specifically we probably don't want to fire a
> sessionCreated() event (because a session was already created by the
> statemachine), we simply want to pass that to our handler.
>
> Thanks.
> Hunter
>
> On 8/1/13 9:54 PM, Ashish wrote:
> > On Fri, Aug 2, 2013 at 7:15 AM, Jon V.  wrote:
> >
> >> To my knowledge the executor filter does not guarantee any kind of
> order.
> >> This means that you should implement the authentication phase before the
> >> executor.
> >>
> > This is correct, with Executor filter ordering is not guaranteed. Do you
> > need an executor filter there?
> > It's usage is recommended if you have some intensive task in chain or in
> > IoHandler.
> >
> >
> >> Io->prorocol->authentication->executor->handler
> >>
> > This sound good. Alternative is to use OrderedThreadPoolExecutor, but go
> > simple first.
> > Implement stuff without Executor filter and then push that in if needed.
> >
> >
> >> You cannot lock on out of order messaging without a queue and attempt to
> >> re-order the messages.
> >> On Aug 1, 2013 9:33 PM, "Hunter McMillen"  wrote:
> >>
> >>> Sorry, the code is probably more useful to see, here is the entry point
> >>> to our application:
> >>>
> >>> acceptor = new NioSocketAcceptor(
> >>> Runtime.getRuntime().availableProcessors() );
> >>> acceptor.getFilterChain().addLast("executor", new
> >>> ExecutorFilter( Executors.newCachedThreadPool()));
> >>> acceptor.getFilterChain().addLast("logger",
> >>> MudConfig.Logging.getFilter());
> >>> acceptor.getFilterChain().addLast("codec",
> >>> new ProtocolCodecFilter(
> >>> new TextLineEncoder(), new CommandDecoder()
> >>> )
> >>> );
> >>>
> >>> More importantly, my main question is how I can link the DONE state of
> >>> the state machine (AuthenticationHandler) and the IoHandlerAdapter. I
> >>> can post the code for these also, I just didn't want to overload the
> >>> thread.
> >>>
> >>> Thanks.
> >>> Hunter
> >>> On 8/1/13 5:47 PM, Jon wrote:
> >>>> You are not using an executor filter right? You have to implement
> >>> locking during the authentication phase if you are using thread
> >> scheduling.
> >>>> Sent from my iPhone
> >>>>
> >>>> On Aug 1, 2013, at 5:31 PM, Hunter McMillen 
> >> wrote:
> >>>>> Hello,
> >>>>>
> >>>>> I recently started working on a project with a friend that is a
> >>> text-based game. We were having trouble with ReadFuture's when trying
> to
> >>> get a username/password combination from the user so we decided to
> follow
> >>> the state machine example from Tapedeck TCP server on Mina's homepage:
> >>>
> >>
> http://mina.apache.org/mina-project/xref/org/apache/mina/example/tapedeck/
> >>>>> I have gotten the state machine to a point where it seems to be
> >> working
> >>> well. It starts, reads a username, then a password, then has some logic
> >> to
> >>> restart based on error; or it prints a message 'Authenticated'.
> >>>>> However our main application logic is going to be (our plan at least)
> >>> held in an IoHandlerAdapter, my question is what is a good way to
> >> integrate
> >>> the two of these:
> >>>>> 1) The state machine authentication filter from the example above
> >>>>> 2) An IoHandlerAdapter that will track information about connected
> >>> users and sessions
> >>>>> My confusion mainly lies in how to transition between the state
> >> machine
> >>> and the IoHandlerAdapter since they both respond to /sessionCreated
> /and
> >>> /sessionOpened /events.
> >>>>> Any help, ideas, or input would be appreciated.
> >>>>>
> >>>>> Thanks.
> >>>>> Hunter
> >>>
> >
> >
>
>


Re: Using an Authentication Filter and IoHandlerAdapter

2013-08-01 Thread Jon V.
To my knowledge the executor filter does not guarantee any kind of order.
This means that you should implement the authentication phase before the
executor.

Io->prorocol->authentication->executor->handler

You cannot lock on out of order messaging without a queue and attempt to
re-order the messages.
On Aug 1, 2013 9:33 PM, "Hunter McMillen"  wrote:

> Sorry, the code is probably more useful to see, here is the entry point
> to our application:
>
> acceptor = new NioSocketAcceptor(
> Runtime.getRuntime().availableProcessors() );
> acceptor.getFilterChain().addLast("executor", new
> ExecutorFilter( Executors.newCachedThreadPool()));
> acceptor.getFilterChain().addLast("logger",
> MudConfig.Logging.getFilter());
> acceptor.getFilterChain().addLast("codec",
> new ProtocolCodecFilter(
> new TextLineEncoder(), new CommandDecoder()
> )
> );
>
> More importantly, my main question is how I can link the DONE state of
> the state machine (AuthenticationHandler) and the IoHandlerAdapter. I
> can post the code for these also, I just didn't want to overload the
> thread.
>
> Thanks.
> Hunter
> On 8/1/13 5:47 PM, Jon wrote:
> > You are not using an executor filter right? You have to implement
> locking during the authentication phase if you are using thread scheduling.
> >
> > Sent from my iPhone
> >
> > On Aug 1, 2013, at 5:31 PM, Hunter McMillen  wrote:
> >
> >> Hello,
> >>
> >> I recently started working on a project with a friend that is a
> text-based game. We were having trouble with ReadFuture's when trying to
> get a username/password combination from the user so we decided to follow
> the state machine example from Tapedeck TCP server on Mina's homepage:
> http://mina.apache.org/mina-project/xref/org/apache/mina/example/tapedeck/
> >>
> >> I have gotten the state machine to a point where it seems to be working
> well. It starts, reads a username, then a password, then has some logic to
> restart based on error; or it prints a message 'Authenticated'.
> >>
> >> However our main application logic is going to be (our plan at least)
> held in an IoHandlerAdapter, my question is what is a good way to integrate
> the two of these:
> >>
> >> 1) The state machine authentication filter from the example above
> >> 2) An IoHandlerAdapter that will track information about connected
> users and sessions
> >>
> >> My confusion mainly lies in how to transition between the state machine
> and the IoHandlerAdapter since they both respond to /sessionCreated /and
> /sessionOpened /events.
> >>
> >> Any help, ideas, or input would be appreciated.
> >>
> >> Thanks.
> >> Hunter
>
>


Re: Using an Authentication Filter and IoHandlerAdapter

2013-08-01 Thread Jon
You are not using an executor filter right? You have to implement locking 
during the authentication phase if you are using thread scheduling. 

Sent from my iPhone

On Aug 1, 2013, at 5:31 PM, Hunter McMillen  wrote:

> Hello,
> 
> I recently started working on a project with a friend that is a text-based 
> game. We were having trouble with ReadFuture's when trying to get a 
> username/password combination from the user so we decided to follow the state 
> machine example from Tapedeck TCP server on Mina's homepage: 
> http://mina.apache.org/mina-project/xref/org/apache/mina/example/tapedeck/
> 
> I have gotten the state machine to a point where it seems to be working well. 
> It starts, reads a username, then a password, then has some logic to restart 
> based on error; or it prints a message 'Authenticated'.
> 
> However our main application logic is going to be (our plan at least) held in 
> an IoHandlerAdapter, my question is what is a good way to integrate the two 
> of these:
> 
> 1) The state machine authentication filter from the example above
> 2) An IoHandlerAdapter that will track information about connected users and 
> sessions
> 
> My confusion mainly lies in how to transition between the state machine and 
> the IoHandlerAdapter since they both respond to /sessionCreated /and 
> /sessionOpened /events.
> 
> Any help, ideas, or input would be appreciated.
> 
> Thanks.
> Hunter


RE: Does MINA 2.0.4 supports IPV6

2013-07-31 Thread Jon V.
I am not setup to do anything in Mina at the moment.

You know how to setup regex patterns in Java?

Its as simple as converting the inetaddress to a string and comparing with
the regex.

If condition is true, close the session.
On Jul 30, 2013 1:17 AM, "Nitin Phuria"  wrote:

> No I am not using any wildcards in blacklist filter of MINA. All the IP
> Addresses are IPV4 type and are individual IPs. Could you pls give me some
> leads on your statement "You could build your own string and pattern based
> blacklist filter for IPV6" so that I can try it.
>
> Thanks And Regards,
> Nitin Phuria
>
> -Original Message-
> From: Jon V. [mailto:sybersn...@gmail.com]
> Sent: Saturday, July 27, 2013 12:27 AM
> To: users@mina.apache.org; nit...@integramicro.com
> Subject: Re: Does MINA 2.0.4 supports IPV6
>
> Are you using wildcards in the blacklist filter?  You could build your own
> string and pattern based blacklist filter for IPV6 in under 30 minutes.
>
>
> On Fri, Jul 26, 2013 at 3:10 AM, Nitin Phuria
> wrote:
>
> > The issue is registered in JIRA see the below link.
> > https://issues.apache.org/jira/browse/DIRMINA-957
> >
> > Thanks And Regards,
> > Nitin Phuria
> >
> > -Original Message-
> > From: Emmanuel Lécharny [mailto:elecha...@gmail.com]
> > Sent: Thursday, July 25, 2013 6:49 PM
> > To: users@mina.apache.org
> > Subject: Re: Does MINA 2.0.4 supports IPV6
> >
> > Le 7/25/13 1:47 PM, Nitin Phuria a écrit :
> > > Hello All,
> > >
> > > MINA build in BlacklistFilter does not support IPV6 address. If MINA
> > itself
> > > supports binding to IPV4 and IPV6 why this restriction was kept in
> > > BlacklistFilter.
> >
> > That's a different problem...
> >
> >
> > > I checked the org.apache.mina.filter.firewall.Subnet class
> > > in MINA sources and found that it specifically checks for Inet4Address
> > >
> > > if (!(subnet instanceof Inet4Address))
> > > {
> > >  throw new IllegalArgumentException("Only IPv4 supported");
> > > }
> > >
> > > We are using this filter and now supports only IPV4
> > >
> > > Pls advice.
> >
> > Please fill a JIRA, we are going to look at it.
> >
> > ATM, I suggest you remove this check from the code, and see if it works
> > for you. If so, we could then patch MINA, this is probably the fastest
> > way to solve your issue.
> >
> >
> > --
> > Regards,
> > Cordialement,
> > Emmanuel Lécharny
> > www.iktek.com
> >
> >
> >
>
>


Re: Does MINA 2.0.4 supports IPV6

2013-07-26 Thread Jon V.
Are you using wildcards in the blacklist filter?  You could build your own
string and pattern based blacklist filter for IPV6 in under 30 minutes.


On Fri, Jul 26, 2013 at 3:10 AM, Nitin Phuria wrote:

> The issue is registered in JIRA see the below link.
> https://issues.apache.org/jira/browse/DIRMINA-957
>
> Thanks And Regards,
> Nitin Phuria
>
> -Original Message-
> From: Emmanuel Lécharny [mailto:elecha...@gmail.com]
> Sent: Thursday, July 25, 2013 6:49 PM
> To: users@mina.apache.org
> Subject: Re: Does MINA 2.0.4 supports IPV6
>
> Le 7/25/13 1:47 PM, Nitin Phuria a écrit :
> > Hello All,
> >
> > MINA build in BlacklistFilter does not support IPV6 address. If MINA
> itself
> > supports binding to IPV4 and IPV6 why this restriction was kept in
> > BlacklistFilter.
>
> That's a different problem...
>
>
> > I checked the org.apache.mina.filter.firewall.Subnet class
> > in MINA sources and found that it specifically checks for Inet4Address
> >
> > if (!(subnet instanceof Inet4Address))
> > {
> >  throw new IllegalArgumentException("Only IPv4 supported");
> > }
> >
> > We are using this filter and now supports only IPV4
> >
> > Pls advice.
>
> Please fill a JIRA, we are going to look at it.
>
> ATM, I suggest you remove this check from the code, and see if it works
> for you. If so, we could then patch MINA, this is probably the fastest
> way to solve your issue.
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>
>


Rules

2013-07-23 Thread Jon V.
To the MINA mailing list owner.  Can we setup a rule requiring the project
name in the subject line? e.g. [MINA] , [SSHD]


Re: Does MINA 2.0.4 supports IPV6

2013-07-19 Thread Jon
Just create an ipv6 socket address object for use when binding the socket. It 
is really no different than v4

Sent from my iPad

On Jul 19, 2013, at 12:06 AM, "Nitin Phuria"  wrote:

> Dear All,
> 
> 
> 
>I want following information about MINA Framework Version 2.0.4
> as we have created MINA V2.0.4 based Server and client. Now we want it to
> support IPV6 so below are little information we are looking for.
> 
> 
> 
> 1.Does MINA 2.0.4 supports IPV6? 
> 2.If answer to Question 1 is yes then how to give IPV6 IP address to
> MINA for binding? 
> 3.Any Sample for the same will be a great help. 
> 
> 
> 
> 
> 
> Thanks And Regards,
> Nitin Phuria
> 
> 
> 


Re: Blocking IO tasks

2013-06-28 Thread Jon
You could have used the executor filter to do this. All depends on the lengths 
you want to go through for difference performance profiles. 

Sent from my iPhone

On Jun 28, 2013, at 1:11 PM, Zlatko Josic  wrote:

> Hi,
> 
> We created server based on MINA framework. Every request has logic that
> writes to database.
> We creates separated thread pool for these taks.
> This means that MINA's worker thread pool submits taks to our pool where
> they are executed.
> Is this good approach ?
> 
> Thanks
> 
> Zlaja


Re: SSL Server Allows Anonymous Authentication Vulnerability

2013-05-27 Thread Jon
Someone can correct me if I am wrong but this probably happens with a self 
signed certificate. They are anonymous by nature because no certificate 
authority will certify it. 

Sent from my iPad

On May 24, 2013, at 8:52 AM, "Rajiv Kasera"  wrote:

> Hi,
>  
> I am using SSLFilter for enabling SSL on my mina server. On Vulnerability 
> assessment the report indicated “SSL Server Allows Anonymous Authentication 
> Vulnerability”. Can someone suggest on what configuration changes can prevent 
> this vulnerability.
>  
> Below is the code snippet for enabling sslfilter:
>  
>  SslFilter sslFilter = new SslFilter(new 
> SSLContextGenerator().getSslContext());
>  sslFilter.setUseClientMode(false);
>  sslFilter.setEnabledCipherSuites(strCiphers);
>  chain.addLast("sslFilter", sslFilter);
>  
> I tried sslFilter.setNeedClientAuth(true) but it does not work.
>  
> Thanks,
> Rajiv


Re: XML Protocol with initial ASCII handshake

2013-04-27 Thread Jon V.
1) You obtain the next filter and call messageReceived there.  Mina will
automatically wrap the last filter and call the handler.
2) nextFilter.filterWrite(session, new DefaultWriteRequest(out,
writeRequest.getFuture(), writeRequest.getDestination()));

On Fri, Apr 26, 2013 at 2:45 PM, Max Larsson
wrote:

> Hi Emmanuel,
>
> i have now a IoFilter which implement the initial connection
> establishing. But i have two question.
>
> 1) In my filter how do i send response to a messageRecived, so that
> the IoHandler does get informed.
>
> 2) The responses are only flushed out, during application shutdown.
> (J used flip() before sending the buffer via a DefaultWriteRequest
> down the nextFilter with filterWrite.
>
> I think the two questions relates somehow?
>
> regards
>
> Max
>
>
> On 18.04.13 02:00, Emmanuel Lécharny wrote:
>
>> Le 4/17/13 7:56 PM, Max Larsson a écrit :
>>
>>> Hi Emmanuel,
>>>
>>> Somehow i habe completly missed The concept of of filters. You are right
>>> They seem to fit perfectly. Just a question are iohanders even iofilters?
>>>
>> No. They are two different interfaces. The IoHandler just process the
>> events that are being generated by the IoService and propagated through
>> the IoFilters.
>>
>>
>>
>
> --
> __**__**_
>
> Max Larsson
> facilityboss GmbH
> Rheinstrasse 75, 64295 Darmstadt / Germany
> Handelsregister Darmstadt, HRB 86193
> Geschäftsführer: Dipl.-Inform. Max Lars Robert Larsson
>
> Mobil: +49 179 2184428
> Email: max.lars...@facilityboss.biz
>


Re: XML Protocol with initial ASCII handshake

2013-04-17 Thread Jon V
Data-->Filters-->Handler  

Filters are pretty much the same as a handler just they can be stacked 
horizontally and there is only one handler.  

--  
Jon V
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Wednesday, April 17, 2013 at 1:56 PM, Max Larsson wrote:

> Hi Emmanuel,
>  
> Somehow i habe completly missed The concept of of filters. You are right
> They seem to fit perfectly. Just a question are iohanders even iofilters?
>  
> regrads
>  
> Max
>  
> Am 17.04.2013 um 19:16 schrieb Emmanuel Lécharny  (mailto:elecha...@gmail.com)>:
>  
> > Le 4/17/13 6:48 PM, Max Larsson a écrit :
> > > Hi,
> > >  
> > > The XML size is send in the front of the actual data.
> >  
> > Ok, fine, then you can gather the XML in a raw byte[] while decoding
> > your own protocol. When done, you can parse the XML file in your
> > decoder. No need to have two filters; but you can do that. The message
> > sent to the next filter is just the payload (the XML data).
> >  
> >  
> >  
> > --  
> > Regards,
> > Cordialement,
> > Emmanuel Lécharny
> > www.iktek.com (http://www.iktek.com)  
> >  
>  
>  
>  




Re: XML Protocol with initial ASCII handshake

2013-04-17 Thread Jon
This is simple. Two filters. One for handshake one for protocol. After 
handshake is done. Disable the first through some session variable. 

Sent from my iPhone

On Apr 17, 2013, at 11:51 AM, Emmanuel Lécharny  wrote:

> Le 4/17/13 5:17 PM, Max Larsson a écrit :
>> Hi,
> Hi,
>> 
>> I'm using MINA to develop a client for a mainly XML based protocol.
> Not the simplest kind of protocol to decode ...
> 
>> 
>> And i have some problems to figure out how to realize it in the best
>> way. The cause of the problem is that the Protocol has upon
>> a successful connection to the IP/Port a initial procedure to select
>> the desired protocol and version is performed, before the actual XML
>> Protocol starts.
>> 
>> Up on now i created a StateMachine (similar to the TapeDeck Example on
>> the website) which models the initial procedure. That seems to work.
>> What i now wanted to do is, when this StateMachine has reached it
>> connect state (and the actually XML protocol starts), to forward
>> all message to another StateMaschine which works upon the first one.
>> Alternative i thought about to implement a custom IOConnector,
>> which uses the first StateMachine to establish a connection.
> There is a big problem with this approach : you won't know when the XML
> data will be fully received before having parsed it...
> 
> Unless your encapsulating protocol gives you the size of the XML data !
> 
> Is it the case ?
> 
> 
> -- 
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com 
> 


Re: changes the bytes of transmitting byte Array through apache camel mina UDP

2013-03-01 Thread Jon V
+1 for great analogy.  


On Friday, March 1, 2013 at 9:12 AM, Emmanuel Lécharny wrote:

> Le 3/1/13 9:50 AM, Tejas Patel a écrit :
> > Problem :
> >  
> > When i transmit the byte array of [56, 34, 0, 4, -79, 1] from one device to
> > another device on using Apache Camel Mina UDP endpoint, at receiver side 
> > byte
> > Array is changed like [56, 34, 0, 4, -17, -65, -67, 1]. but when i transmit 
> > byte
> > array like [56,34,0,4,78,0] from one device to another using same approach 
> > it
> > will receive same byte array.
> >  
> > Can you suggest me how to resolve the issue?
> No.
>  
> Your desciption is at best extremely vague. It's like if you are asking
> why a plane has crashed without giving us nothing but a picture of the
> crashed plane...
>  
>  
>  
>  
> --  
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com (http://www.iktek.com)  
>  
>  




Re: When will Mina 2.0.8 generally available?

2013-02-01 Thread Jon
http://www.apache.org/dyn/closer.cgi/mina/mina/2.0.7/apache-mina-2.0.7-src.zip

Sent from my iPhone

On Feb 1, 2013, at 11:22 AM, Lei Ma  wrote:

> Thank you Jon.
> 
> How do I download the mina-http project?
> 
> I git cloned the following and the http encoder/decoder doesn't seem to work 
> with 2.0.7 core
> git clone http://git-wip-us.apache.org/repos/asf/mina.git
> 
> Please help.
> 
> Lei
> 
> 
> -Original Message-
> From: Jon [mailto:sybersn...@gmail.com] 
> Sent: Friday, February 01, 2013 10:09 AM
> To: users@mina.apache.org
> Cc: users@mina.apache.org; elecha...@apache.org
> Subject: Re: When will Mina 2.0.8 generally available?
> 
> Basic http support is in the Mina-http project. You have to download the 
> sources and build the library. 
> 
> Sent from my iPhone
> 
> On Feb 1, 2013, at 9:59 AM, Lei Ma  wrote:
> 
>> I need it to support HTTP.
>> 
>> Thanks a lot.
>> 
>> Lei
>> 
>> -Original Message-
>> From: Emmanuel Lécharny [mailto:elecha...@gmail.com] 
>> Sent: Thursday, January 31, 2013 5:27 PM
>> To: users@mina.apache.org
>> Subject: Re: When will Mina 2.0.8 generally available?
>> 
>> Is there aything in 2.0.7 that you need to get corrected ?
>> 
>> -- 
>> Regards,
>> Cordialement,
>> Emmanuel Lécharny
>> www.iktek.com 
>> 


Re: When will Mina 2.0.8 generally available?

2013-02-01 Thread Jon
Basic http support is in the Mina-http project. You have to download the 
sources and build the library. 

Sent from my iPhone

On Feb 1, 2013, at 9:59 AM, Lei Ma  wrote:

> I need it to support HTTP.
> 
> Thanks a lot.
> 
> Lei
> 
> -Original Message-
> From: Emmanuel Lécharny [mailto:elecha...@gmail.com] 
> Sent: Thursday, January 31, 2013 5:27 PM
> To: users@mina.apache.org
> Subject: Re: When will Mina 2.0.8 generally available?
> 
> Is there aything in 2.0.7 that you need to get corrected ?
> 
> -- 
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com 
> 


Fw: Session Closed

2013-01-18 Thread Jon V
I'm looking for how Mina is determining a close from NIO. Since NIO does not 
have any direct method to detect closure.(without calling write/read and 
getting a -1)



  
>  
> On Friday, January 18, 2013 at 9:37 AM, Emmanuel Lécharny wrote:
>  
> > Le 1/18/13 2:48 PM, Jon V a écrit :
> > > Emmanuel,  
> > >  
> > > I am trying to find out how Mina is detecting Session closures for 2.0.7. 
> > > Source searches do not seem to help. Can you point me in the right 
> > > direction?  
> >  
> > Depends.
> >  
> > - If the session is cleanly closed, your IoHandler will received a
> > SessionClosed event. You just have to implement the sessionClosed(
> > IoSession ) method in your IoHandler.
> >  
> > - If the session is brutally closed, like when you unplug your network
> > cable from the socket, the remote peer will never be informed. the only
> > solutio is to check for the session idleness. When a session becomes
> > idle (the idle delay is configurable), you will received a SessionIdle
> > event. You have to implement the sessionIdle( IoSession ) method to trap
> > this event and decide if the session has to be deleted.
> >  
> > Is this what you are looking for ?
> >  
> >  
> > --  
> > Regards,
> > Cordialement,
> > Emmanuel Lécharny
> > www.iktek.com (http://www.iktek.com)  
> >  
> >  
> >  
>  
>  



Session Closed

2013-01-18 Thread Jon V
Emmanuel, 

I am trying to find out how Mina is detecting Session closures for 2.0.7.  
Source searches do not seem to help.  Can you point me in the right direction? 

-- 
Jon V




Re: Patch for IoBuffer management in IoProcessor 2.0.7

2013-01-03 Thread Jon V.
https://issues.apache.org/jira/browse/DIRMINA-929

On Thu, Jan 3, 2013 at 3:24 PM, Arnaud bourree wrote:

> http://issues.apache.org/jira/browse/DIRMINA
>
> 2013/1/3 Jon V. :
> > JIRA location?
> >
> > On Thu, Jan 3, 2013 at 11:35 AM, Emmanuel Lécharny  >wrote:
> >
> >> Le 1/3/13 5:12 PM, Jon V. a écrit :
> >> > Sorry that this is the entire file.  I don't have it checked out with
> >> > subversion to create typical patches.
> >> >
> >> > Basically, there are two places where I call free() to release the
> >> IoBuffer
> >> > memory.
> >> >
> >> > The CachedBufferAllocator is totally broken but I am able to get 100%
> >> > recycled Buffers with a custom implementation that I will be happy to
> >> > submit back once I have tested it properly.
> >> >
> >> Hi !
> >>
> >> the patch has been discarded by the mailer.
> >>
> >> Could you create a JIRA and attach the patch ?
> >>
> >> Many thanks !
> >>
> >> --
> >> Regards,
> >> Cordialement,
> >> Emmanuel Lécharny
> >> www.iktek.com
> >>
> >>
>


Re: Mina Core 2.0.7 build fails from source zip

2013-01-03 Thread Jon V.
On Thu, Jan 3, 2013 at 11:37 AM, Emmanuel Lécharny wrote:

> Le 1/3/13 4:50 PM, Jon V. a écrit :
> > I am trying to patch a bug in the IoBuffer caching and it won't build
> > unless I remove the tests from the pom.xml
>
> Hi,
>
> can you provide a bit more information, like :
> - the used JVM
>
-latest, 64 bit

> - the OS (windows, but which version ?)
>
windows server 2008 r2

> - the Maven version
>
latest

> - the command line you used to run tests
>
mvn package

>
> Also there is a .txt file in
>
>
> C:\Users\Administrator\Downloads\apache-mina-2.0.7-src\apache-mina-2.0.7\src\mina-core\target\surefire-reports
>
this is a folder, I can zip but the mailer ignores attachments?

>
> which contains the error. I'll be interested to review it.
>
>
> Many thanks !
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>


Re: Patch for IoBuffer management in IoProcessor 2.0.7

2013-01-03 Thread Jon V.
JIRA location?

On Thu, Jan 3, 2013 at 11:35 AM, Emmanuel Lécharny wrote:

> Le 1/3/13 5:12 PM, Jon V. a écrit :
> > Sorry that this is the entire file.  I don't have it checked out with
> > subversion to create typical patches.
> >
> > Basically, there are two places where I call free() to release the
> IoBuffer
> > memory.
> >
> > The CachedBufferAllocator is totally broken but I am able to get 100%
> > recycled Buffers with a custom implementation that I will be happy to
> > submit back once I have tested it properly.
> >
> Hi !
>
> the patch has been discarded by the mailer.
>
> Could you create a JIRA and attach the patch ?
>
> Many thanks !
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>


Patch for IoBuffer management in IoProcessor 2.0.7

2013-01-03 Thread Jon V.
Sorry that this is the entire file.  I don't have it checked out with
subversion to create typical patches.

Basically, there are two places where I call free() to release the IoBuffer
memory.

The CachedBufferAllocator is totally broken but I am able to get 100%
recycled Buffers with a custom implementation that I will be happy to
submit back once I have tested it properly.


  1   2   >