Re: Only listen to connections from localhost

2015-01-14 Thread Jose María Zaragoza
2015-01-14 20:26 GMT+01:00 Alberto Garcia agarciaill...@gmail.com:
 Hi.
 I want to know how can I do to start a server but only listen to
 connections that comes from localhost. When you create the server using
 SshServer sshd = SshServer.setUpDefaultServer(); it starts listening in the
 port indicated for all the IPs (0.0.0.0). How can I change that so I can
 ssh only from within the machine where I am running mina?


I don't know, but you can try to set the host to 127.0.0.01


 Regards
 --
 Alberto

 GPG Public Key: http://goo.gl/NisBgi


Re: Bug (?) getting encoder in TextLineCodecFactory in Mina 1.1.7

2013-10-04 Thread Jose María Zaragoza
Thanks
I'd like it but I'm having problems with a lot of FIFO file
descriptores with that release




2013/10/4 Emmanuel Lécharny elecha...@gmail.com:
 Le 10/3/13 10:32 PM, Jose María Zaragoza a écrit :
 Hello:

 I'm using Mina 1.1.7

 I strongly suggest that you switch to MINA 2.0.7. We don't mainatin any
 more 1.1.7


 --
 Regards,
 Cordialement,
 Emmanuel Lécharny
 www.iktek.com



Re: Bug (?) getting encoder in TextLineCodecFactory in Mina 1.1.7

2013-10-04 Thread Jose María Zaragoza
OK.
I'm going to debug that issue and I will tell you my conclusions

So far, I only can know that the same code running on Tomcat but with
lastest MINA release creates a lot of FIFO file descriptors, but 1.1.7
doesn't,

Thanks

2013/10/4 Emmanuel Lécharny elecha...@gmail.com:
 Le 10/4/13 8:26 AM, Jose María Zaragoza a écrit :
 Thanks
 I'd like it but I'm having problems with a lot of FIFO file
 descriptores with that release

 You still should keep going with MINA 2.0.7, otherwise you are totally
 on yoru own, with a version which has many unfixed issues.

 Now, I'm orry, but there is little we can do with the FIFO pipe problem
 you are describing, as we know nothing about the way you are using MINA
 in Tomcat.

 As this point, a complete description of what you try to do, and how you
 do it could help us helping you.


 --
 Regards,
 Cordialement,
 Emmanuel Lécharny
 www.iktek.com



Re: Bug (?) getting encoder in TextLineCodecFactory in Mina 1.1.7

2013-10-04 Thread Jose María Zaragoza
Yes, 2.0.7

I've checked that closing sessions isn't enough to free all underlying
resources and I need to execute dispose() method on SocketConnector
object
I've see that I only execute session.close() , there is a waiting JVM
thread what never ends








2013/10/4 Bugra Cakir bug...@mobiliz.com.tr:


 But we don't get this problem. We are using Mina 2.0.7 ? Isn't it strange ?

 Bugra


 4 Eki 2013 tarihinde 15:10 saatinde, Jose María Zaragoza 
 demablo...@gmail.com
  şunları yazdı:

 OK
 I think that I found the cause of the problem


 I need to perform

 SocketConnector.dispose()

 I only was closing session with session.close()


 What is the right way to finish a communitcation  immediately?

 session.close():
 socket.dispose();
 ?

 or is it only  enough to perfom socket.dispose(); ?


 Thanks

















 2013/10/4 Jose María Zaragoza demablo...@gmail.com:
 I'm closing the same resources with MINA 2.x and MINA 1.1.x.
 Maybe there are new resources in MINA 2.x which should be close and I
 don't know them

 I'm going to start standalone tests because I had to downgrade  from
 2.0.7 to 1.1.7 because the application is running on production
 enviroment and I couldn't do many tests



 2013/10/4 Emmanuel Lécharny elecha...@gmail.com:
 Le 10/4/13 9:06 AM, Jose María Zaragoza a écrit :
 OK.
 I'm going to debug that issue and I will tell you my conclusions

 So far, I only can know that the same code running on Tomcat but with
 lastest MINA release creates a lot of FIFO file descriptors, but 1.1.7
 doesn't,

 You most certainly have some opened streams that need to be closed. The
 way MINA 1 works is very different from MINA 2, so be sure you always
 cleanup whatever resource you use in your code.


 --
 Regards,
 Cordialement,
 Emmanuel Lécharny
 www.iktek.com




Bug (?) getting encoder in TextLineCodecFactory in Mina 1.1.7

2013-10-03 Thread Jose María Zaragoza
Hello:

I'm using Mina 1.1.7

I'm getting problems when i try to use a custom ProtocolCodecFilter +
TextLineCodecFactory
Decoding works fine but encoding doesn't: method getEncoder() is never
invoked (  but getDecoder() does )


This the code:


I add the filter by passing a config object when connecting,   like

config.getFilterChain().addLast(filter, new ProtocolCodecFilter(new
CharacterDelimiterCodecFactory (\0','UTF-8')));



and CharacterDelimiterCodecFactory class is defined as

public class CharacterDelimiterCodecFactory extends TextLineCodecFactory
{
private TextLineDecoder decoder = null;
private TextLineDecoder encoder = null;

public CharacterDelimiterCodecFactory(String delimiter, String charSet)
{
decoder = new TextLineDecoder(Charset.forName(charSet),new
LineDelimiter(delimiter));
encoder= new TextLineEncder(Charset.forName(charSet),new
LineDelimiter(delimiter));
}
public ProtocolDecoder getDecoder()
{

   return decoder;
   }

public ProtocolEncoder getEncoder()
{

   return encoder;
   }

}


What is wrong ? any ideas or w/a ?

FYI , Mina 2.0 all  works fine but I can't migrate

Thanks and regards


IoSession.close() method

2013-10-02 Thread Jose María Zaragoza
Hello:

I'm working with Mina 1.x ( old, I know ) and I've got a question

About docs, IoSession.close() closes the session immediately.

If i've got

session.write(data)
session.close()


can be sure that data is sent properly ?

o do I need to perform session.close() on messageSent method ?


Thanks


Many anon_inode and FIFO pipes opened ( leak fd )

2013-10-01 Thread Jose María Zaragoza
Hi:

I'm using Apache Mina 2.0.7

I'm waching by lsof command *A LOT OF* file descriptors opened like

java  24512tomcat 6440u  REG0,90
3779 anon_inode

and

java  24512tomcat 6438r FIFO0,8  0t0
1775475918 pipe
java  24512tomcat 6439w FIFO0,8  0t0
1775475918 pipe


And increasing

I need help
What could be happening ?

I'm closing my sockets with this code


try
{
if (this.socket != null  this.socket.getFilterChain() != null)
this.socket.getFilterChain().clear();
}
catch(Exception e)
{
l.error(*#*#*# Cannot clear filter chain {} , e);
}
if (this.session != null  this.session.isConnected())
{

this.session.close(b);
l.info(*#*#*# Socket session closed);
}


Any wrong ? Should i check  this.session.isConnected() before invoking
this.session.close(b);?

Thanks and regards


Many pipe file descriptors opened

2013-09-30 Thread Jose María Zaragoza
Hello:

I'm using the Apache Mina 2.0.7 + Tomcat 6.0.23


I'm watching ( lsof ) a lot of file descriptors opened such as

java 13162 tomcat 476r FIFO 0,8 0t0 680740932 pipe
java 13162 tomcat 477r FIFO 0,8 0t0 680740932 pipe
java 13162 tomcat 479r FIFO 0,8 0t0 680740933 pipe


I wonder if this could be caused by IoFilters

Must I remove IoFilters from FilterChain before disconnecting a socket ?
Any ideas ?


Thanks and regards


Re: Many pipe file descriptors opened

2013-09-30 Thread Jose María Zaragoza
Thanks
I think I didn't explain myself

I've got a lot of those messages

java  13162tomcat 2140r FIFO0,8   0t0
681610237 pipe
java  13162tomcat 2141w FIFO0,8   0t0
681610237 pipe
java  13162tomcat 2143r FIFO0,8   0t0
681610238 pipe
java  13162tomcat 2144w FIFO0,8   0t0
681610238 pipe
java  13162tomcat 2146r FIFO0,8   0t0
681610239 pipe
java  13162tomcat 2147w FIFO0,8   0t0
681610239 pipe
java  13162tomcat 2150r FIFO0,8   0t0
681676970 pipe
java  13162tomcat 2151r FIFO0,8   0t0
681676970 pipe
java  13162tomcat 2153r FIFO0,8   0t0
681676971 pipe
java  13162tomcat 2154r FIFO0,8   0t0
681676971 pipe

They aren't sockets file descriptors , but pipe file descriptors

Looks like a leak but I don't know why, because I'm closing underlying socket
Where could be the leak ?

Thanks and regards



2013/9/30 Emmanuel Lécharny elecha...@gmail.com:
 Le 9/30/13 12:30 PM, Jose María Zaragoza a écrit :
 Hello:

 I'm using the Apache Mina 2.0.7 + Tomcat 6.0.23


 I'm watching ( lsof ) a lot of file descriptors opened such as

 java 13162 tomcat 476r FIFO 0,8 0t0 680740932 pipe
 java 13162 tomcat 477r FIFO 0,8 0t0 680740932 pipe
 java 13162 tomcat 479r FIFO 0,8 0t0 680740933 pipe


 I wonder if this could be caused by IoFilters

 Must I remove IoFilters from FilterChain before disconnecting a socket ?
 Any ideas ?
 No, this has nothing to do with IoFilters. It's just that MINA defaults
 to use Nb Processor +1 IoProcessors, each one of them being listening on
 a socket. It's very likely that you have a dual-core processor, so 3
 IoProcessors have been opened.



 --
 Regards,
 Cordialement,
 Emmanuel Lécharny
 www.iktek.com



Re: Send a message immediatly

2013-07-26 Thread Jose María Zaragoza
OK. Thanks.

One question more:

if I create a new filter  (iofilter1 ) , so I have


iohandler --- iofilter1


When I receive a message , messageReceived on iofilter1 is executed
and , finally , messageReceived on iohandler is executed

If I put the code that sends test in iofilter1 and  ( doing other
stuffs ) in iohandler's messageReceived
would it work ? i mean , would be test sent before iohandler's
messageReceived is executed?

Thanks



2013/7/26 Emmanuel Lécharny elecha...@gmail.com:
 Le 7/26/13 11:46 AM, Jose María Zaragoza a écrit :
 Hello:


 I'm using Mina Core 2.0.7

 I use BufferedWriteFilter to send data and every time I write data for
 sending it ,  I flush this filter manually by this code:

 this.session.write(data);
 ((BufferedWriteFilter) f).flush(this.session);



 Sometimes I've to send data from the messageReceived() callback method.
 I've observed that until  messageReceived() finishes , data is not sent

 Example:

 public void messageReceived(IoSession session, Object message) throws 
 Exception
 {

 session.write(test);
 ((BufferedWriteFilter) f).flush(session);

 .
 .  ( doing stuffs )
 ..

 ( **here**, test is sent )
 }


 How I can send data  immediatly in messageReceived()  ?


 You can't. Or if you want to do so, then do your write, and move the
 logic you execute after the call to write() into the messageSent() method.

 --
 Regards,
 Cordialement,
 Emmanuel Lécharny
 www.iktek.com



Re: Send a message immediatly

2013-07-26 Thread Jose María Zaragoza
Anyway, I tried your solution and that worked for me
Thanks

2013/7/26 Jose María Zaragoza demablo...@gmail.com:
 OK. Thanks.

 One question more:

 if I create a new filter  (iofilter1 ) , so I have


 iohandler --- iofilter1


 When I receive a message , messageReceived on iofilter1 is executed
 and , finally , messageReceived on iohandler is executed

 If I put the code that sends test in iofilter1 and  ( doing other
 stuffs ) in iohandler's messageReceived
 would it work ? i mean , would be test sent before iohandler's
 messageReceived is executed?

 Thanks



 2013/7/26 Emmanuel Lécharny elecha...@gmail.com:
 Le 7/26/13 11:46 AM, Jose María Zaragoza a écrit :
 Hello:


 I'm using Mina Core 2.0.7

 I use BufferedWriteFilter to send data and every time I write data for
 sending it ,  I flush this filter manually by this code:

 this.session.write(data);
 ((BufferedWriteFilter) f).flush(this.session);



 Sometimes I've to send data from the messageReceived() callback method.
 I've observed that until  messageReceived() finishes , data is not sent

 Example:

 public void messageReceived(IoSession session, Object message) throws 
 Exception
 {

 session.write(test);
 ((BufferedWriteFilter) f).flush(session);

 .
 .  ( doing stuffs )
 ..

 ( **here**, test is sent )
 }


 How I can send data  immediatly in messageReceived()  ?


 You can't. Or if you want to do so, then do your write, and move the
 logic you execute after the call to write() into the messageSent() method.

 --
 Regards,
 Cordialement,
 Emmanuel Lécharny
 www.iktek.com



DEAD LOCK: IoFuture.await() was invoked from an I/O processor thread

2013-07-16 Thread Jose María Zaragoza
Hello:

I'm using Mina 2.0.7 and I'm getting this error where close a session


java.lang.IllegalStateException: DEAD LOCK: IoFuture.await() was invoked
from an I/O processor thread.  Please use IoFutureListener or configure a
proper thread model alternatively.

  at
org.apache.mina.core.future.DefaultIoFuture.checkDeadLock(DefaultIoFuture.java:240)

  at
org.apache.mina.core.future.DefaultIoFuture.await0(DefaultIoFuture.java:210)

  at
org.apache.mina.core.future.DefaultIoFuture.awaitUninterruptibly(DefaultIoFuture.java:153)


I'm closing session with the next code:

if (this.session != null)
{

CloseFuture future = this.session.close(false);
future.await(1);
if (!future.isClosed())
throw new Exception(Disconnect timeout after waiting 10 seconds);
}

What could be the right solution?


I don't know why that code fails but the next code doesn't


this.session.write(request);
ReadFuture readFuture = this.session.read();
readFuture.await(10,TimeUnit.SECONDS);

In this case, await() is invoked in  I/O processor thread, but it doesn't
fail



Thanks and regads


Re: DEAD LOCK: IoFuture.await() was invoked from an I/O processor thread

2013-07-16 Thread Jose María Zaragoza
Thanks.
I was executing some logic in callback methods, who are executed in a
separated  IoProcessor thread.
As logic was executed in a thread to process asynchronous callbacks, when
logic tried to close session, an exception was thrown

I'll try don't execute logic code in callbacks methods




2013/7/16 Emmanuel Lécharny elecha...@gmail.com

 Le 7/16/13 11:29 AM, Jose María Zaragoza a écrit :
  Hello:
 
  I'm using Mina 2.0.7 and I'm getting this error where close a session
 
 
  java.lang.IllegalStateException: DEAD LOCK: IoFuture.await() was invoked
  from an I/O processor thread.  Please use IoFutureListener or configure a
  proper thread model alternatively.
 
at
 
 org.apache.mina.core.future.DefaultIoFuture.checkDeadLock(DefaultIoFuture.java:240)
 
at
 
 org.apache.mina.core.future.DefaultIoFuture.await0(DefaultIoFuture.java:210)
 
at
 
 org.apache.mina.core.future.DefaultIoFuture.awaitUninterruptibly(DefaultIoFuture.java:153)
 
 
  I'm closing session with the next code:
 
  if (this.session != null)
  {
 
  CloseFuture future = this.session.close(false);
  future.await(1);
  if (!future.isClosed())
  throw new Exception(Disconnect timeout after waiting 10 seconds);
  }
 
  What could be the right solution?

 You can't close the session and wait for the future to be completed, as
 the future will be updated by the thread you are on.

 Let me explain what's going on :
 - you are on a thread that handle the session. You require this session
 to be closed.
 - the current thread will update a set with the session to be closed
 - the main server thread will process this set when it will be able to
 do it (ie, probably in the next few ms after you closed the session)
 - it's very likely that the main server thread will reuse the same
 thread than the one you hold for the session (unless you specifically
 tell the server to manage threads differently, it will *always* use the
 same thread for a given session. If you have, say, three IoProcessor,
 you will have three threads created, and all the sessions will be evenly
 spreaded on those three threads, but each session will always use the
 same thread)
 - and as you hold the thread waiting for the future to be completed,
 this thread can't be used to update the future status by the main server
 thread...

 what exactly are you trying to do with the check on the session timeout
 ? You can most certainly use the idle event to manage the timeout...


 --
 Regards,
 Cordialement,
 Emmanuel Lécharny
 www.iktek.com




Re: Is there a setting to prevent too many messages coming through?

2013-05-16 Thread Jose María Zaragoza
2013/5/14 Whitener, Winona T. winona.white...@gd-ais.com

 My client is currently set up to fire messages back to my server very
 quickly.  Around-1 - 3 a second.  Does MINA have any type of handling to
 prevent too many messages from coming through?


For me, a message is a high-level concept in a networking communication
I think that it's a server task to control data flow (by session)


BufferedWriterFilter + string encoded

2013-05-13 Thread Jose María Zaragoza
Hello:

I'm using Apache Mina 2.0.7
I need to send a string to a peer
This string can be encoded in any chatset ( by configuration ) and I need
to send it in a buffered way ( I mean, store it in a buffer and flush it )


I've got to implement it with BufferedWriterFilter and works fine , but I
don't like to use an IoBuffer.
Id like to manage String objects ( not IoBuffers , bytes , arrays , etc )
But if I use BufferedWriterFilter , I need to pass it a IoBuffer
And I need to execute flush()  in the filter when I write the string to the
session
IMHO, it's a mess for writing a simple string

I can extend my own  BufferedWriterFilter and hide all these stuffs. And it
could be fine ,
 but I guess this case must be very usual , what is the best way to do it ?

Thanks and regards