Re: SocketConnector problem
Hi, Thank you for your response. You said SocketConnector should be disposed, I wonder when to dispose it? If my application runs as a service, the SocketConnector is held for a long time. Regards HeQi On Mon, May 26, 2008 at 9:47 AM, Tuure Laurinolli [EMAIL PROTECTED] wrote: Michael Qi wrote: Hi, I write a simple program to test SocketConnector, I start 10 connector but when 5 has connected, it hangs. Could you tell me why? Your thread pool runs out of threads. Each SocketConnector consumes two threads from the pool, and because you use an unbounded queue, the pool does not grow. SocketConnectors also consume file descriptors, and need to be disposed properly. Failing to do so causes fd leakage at least in MINA 2.
Re: A big problem: SocketConnector blocked!
Why is there is one selector per SocketConnector? Could it be reused system wide? On Tue, May 20, 2008 at 9:19 AM, 이희승 (Trustin Lee) [EMAIL PROTECTED] wrote: Please provide a working test application, instead of partial code. On Mon, 19 May 2008 22:43:46 +0900, Michael Qi [EMAIL PROTECTED] wrote: Hi, I am using mina 1.1.7 and try to simulate many client to a server for stress test. and I make 50 clientSessoins, each has a SocketConnector, and the ClientSession.start() is : private static ThreadPoolExecutor exService = new ThreadPoolExecutor(20, 40, 60L, TimeUnit.SECONDS, new ArrayBlockingQueueRunnable(30), new ThreadPoolExecutor.DiscardPolicy()); public void start() { connector = new SocketConnector(4, exService); SocketConnectorConfig scfg = connector.getDefaultConfig(); scfg.setThreadModel(ThreadModel.MANUAL); scfg.setConnectTimeout(15); scfg.getFilterChain().addFirst(mmog_protocol_filter, new ProtocolCodecFilter(new MMOGCodecFactory())); ConnectFuture cf = connector.connect(address, new ClientHandler()); cf.join(); if (cf.isConnected()) { session = cf.getSession(); } else { log.error(could not connect cm); return; } Message m = null; m = new Message(); m.setCommand(Message.LOGIN); byte[] body = new byte[16]; byte[] tmp = Util.intToByteArray(streamId); int p = 0, q = 0; for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(x); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(y); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(0); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } m.setBody(body); WriteFuture wf = session.write(m); wf.join(); } The problem is: I new 50 ClientSession and call start one by one : for (ClientSession cs : sessions) { cs.start(); log.debug(start id = + s); s++; } and the log said : 08 May 19 21:31:44,645 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 0 08 May 19 21:31:44,648 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 1 08 May 19 21:31:44,650 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 2 08 May 19 21:31:44,653 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 3 08 May 19 21:31:44,656 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 4 08 May 19 21:31:44,658 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 5 08 May 19 21:31:44,660 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 6 08 May 19 21:31:44,666 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 7 08 May 19 21:31:44,668 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 8 08 May 19 21:31:44,670 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 9 08 May 19 21:32:44,640 [main] ERROR com.qihe.study.ClientSession.start(ClientSession.java:64) com.qihe.study.ClientSession - could not connect server 08 May 19 21:32:44,640 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 10 08 May 19 21:32:44,655 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 11 08 May 19 21:32:44,640 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 10 08 May 19 21:32:44,655 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 11 08 May 19 21:32:44,660 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 12 08 May 19 21:32:44,664 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 13 08 May 19 21:32:44,672 [main] DEBUG
Re: A big problem: SocketConnector blocked!
Hi Lee, I could not send the application, the gmail server report failure. Could I send it direct to your gmail address? Regards HeQi On Tue, May 20, 2008 at 9:19 AM, 이희승 (Trustin Lee) [EMAIL PROTECTED] wrote: Please provide a working test application, instead of partial code. On Mon, 19 May 2008 22:43:46 +0900, Michael Qi [EMAIL PROTECTED] wrote: Hi, I am using mina 1.1.7 and try to simulate many client to a server for stress test. and I make 50 clientSessoins, each has a SocketConnector, and the ClientSession.start() is : private static ThreadPoolExecutor exService = new ThreadPoolExecutor(20, 40, 60L, TimeUnit.SECONDS, new ArrayBlockingQueueRunnable(30), new ThreadPoolExecutor.DiscardPolicy()); public void start() { connector = new SocketConnector(4, exService); SocketConnectorConfig scfg = connector.getDefaultConfig(); scfg.setThreadModel(ThreadModel.MANUAL); scfg.setConnectTimeout(15); scfg.getFilterChain().addFirst(mmog_protocol_filter, new ProtocolCodecFilter(new MMOGCodecFactory())); ConnectFuture cf = connector.connect(address, new ClientHandler()); cf.join(); if (cf.isConnected()) { session = cf.getSession(); } else { log.error(could not connect cm); return; } Message m = null; m = new Message(); m.setCommand(Message.LOGIN); byte[] body = new byte[16]; byte[] tmp = Util.intToByteArray(streamId); int p = 0, q = 0; for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(x); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(y); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(0); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } m.setBody(body); WriteFuture wf = session.write(m); wf.join(); } The problem is: I new 50 ClientSession and call start one by one : for (ClientSession cs : sessions) { cs.start(); log.debug(start id = + s); s++; } and the log said : 08 May 19 21:31:44,645 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 0 08 May 19 21:31:44,648 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 1 08 May 19 21:31:44,650 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 2 08 May 19 21:31:44,653 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 3 08 May 19 21:31:44,656 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 4 08 May 19 21:31:44,658 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 5 08 May 19 21:31:44,660 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 6 08 May 19 21:31:44,666 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 7 08 May 19 21:31:44,668 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 8 08 May 19 21:31:44,670 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 9 08 May 19 21:32:44,640 [main] ERROR com.qihe.study.ClientSession.start(ClientSession.java:64) com.qihe.study.ClientSession - could not connect server 08 May 19 21:32:44,640 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 10 08 May 19 21:32:44,655 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 11 08 May 19 21:32:44,640 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 10 08 May 19 21:32:44,655 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 11 08 May 19 21:32:44,660 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 12 08 May 19 21:32:44,664 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest
A big problem: SocketConnector blocked!
Hi, I am using mina 1.1.7 and try to simulate many client to a server for stress test. and I make 50 clientSessoins, each has a SocketConnector, and the ClientSession.start() is : private static ThreadPoolExecutor exService = new ThreadPoolExecutor(20, 40, 60L, TimeUnit.SECONDS, new ArrayBlockingQueueRunnable(30), new ThreadPoolExecutor.DiscardPolicy()); public void start() { connector = new SocketConnector(4, exService); SocketConnectorConfig scfg = connector.getDefaultConfig(); scfg.setThreadModel(ThreadModel.MANUAL); scfg.setConnectTimeout(15); scfg.getFilterChain().addFirst(mmog_protocol_filter, new ProtocolCodecFilter(new MMOGCodecFactory())); ConnectFuture cf = connector.connect(address, new ClientHandler()); cf.join(); if (cf.isConnected()) { session = cf.getSession(); } else { log.error(could not connect cm); return; } Message m = null; m = new Message(); m.setCommand(Message.LOGIN); byte[] body = new byte[16]; byte[] tmp = Util.intToByteArray(streamId); int p = 0, q = 0; for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(x); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(y); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(0); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } m.setBody(body); WriteFuture wf = session.write(m); wf.join(); } The problem is: I new 50 ClientSession and call start one by one : for (ClientSession cs : sessions) { cs.start(); log.debug(start id = + s); s++; } and the log said : 08 May 19 21:31:44,645 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 0 08 May 19 21:31:44,648 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 1 08 May 19 21:31:44,650 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 2 08 May 19 21:31:44,653 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 3 08 May 19 21:31:44,656 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 4 08 May 19 21:31:44,658 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 5 08 May 19 21:31:44,660 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 6 08 May 19 21:31:44,666 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 7 08 May 19 21:31:44,668 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 8 08 May 19 21:31:44,670 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 9 08 May 19 21:32:44,640 [main] ERROR com.qihe.study.ClientSession.start(ClientSession.java:64) com.qihe.study.ClientSession - could not connect server 08 May 19 21:32:44,640 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 10 08 May 19 21:32:44,655 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 11 08 May 19 21:32:44,640 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 10 08 May 19 21:32:44,655 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 11 08 May 19 21:32:44,660 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 12 08 May 19 21:32:44,664 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 13 08 May 19 21:32:44,672 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 14 and then it hang! after start id = 9 it hanged too! After a while it said could not connect to server Why this? Could you please tell me? Thank you. Regards QiHe
Re: A big problem: SocketConnector blocked!
And the server is using mina SocketAcceptor. On Mon, May 19, 2008 at 9:43 PM, Michael Qi [EMAIL PROTECTED] wrote: Hi, I am using mina 1.1.7 and try to simulate many client to a server for stress test. and I make 50 clientSessoins, each has a SocketConnector, and the ClientSession.start() is : private static ThreadPoolExecutor exService = new ThreadPoolExecutor(20, 40, 60L, TimeUnit.SECONDS, new ArrayBlockingQueueRunnable(30), new ThreadPoolExecutor.DiscardPolicy()); public void start() { connector = new SocketConnector(4, exService); SocketConnectorConfig scfg = connector.getDefaultConfig(); scfg.setThreadModel(ThreadModel.MANUAL); scfg.setConnectTimeout(15); scfg.getFilterChain().addFirst(mmog_protocol_filter, new ProtocolCodecFilter(new MMOGCodecFactory())); ConnectFuture cf = connector.connect(address, new ClientHandler()); cf.join(); if (cf.isConnected()) { session = cf.getSession(); } else { log.error(could not connect cm); return; } Message m = null; m = new Message(); m.setCommand(Message.LOGIN); byte[] body = new byte[16]; byte[] tmp = Util.intToByteArray(streamId); int p = 0, q = 0; for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(x); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(y); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } tmp = Util.floatToByteArray(0); for (q = 0; q 4; p++, q++) { body[p] = tmp[q]; } m.setBody(body); WriteFuture wf = session.write(m); wf.join(); } The problem is: I new 50 ClientSession and call start one by one : for (ClientSession cs : sessions) { cs.start(); log.debug(start id = + s); s++; } and the log said : 08 May 19 21:31:44,645 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 0 08 May 19 21:31:44,648 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 1 08 May 19 21:31:44,650 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 2 08 May 19 21:31:44,653 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 3 08 May 19 21:31:44,656 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 4 08 May 19 21:31:44,658 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 5 08 May 19 21:31:44,660 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 6 08 May 19 21:31:44,666 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 7 08 May 19 21:31:44,668 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 8 08 May 19 21:31:44,670 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 9 08 May 19 21:32:44,640 [main] ERROR com.qihe.study.ClientSession.start(ClientSession.java:64) com.qihe.study.ClientSession - could not connect server 08 May 19 21:32:44,640 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 10 08 May 19 21:32:44,655 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 11 08 May 19 21:32:44,640 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 10 08 May 19 21:32:44,655 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 11 08 May 19 21:32:44,660 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 12 08 May 19 21:32:44,664 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 13 08 May 19 21:32:44,672 [main] DEBUG com.qihe.study.ClientTest.main(ClientTest.java:107) com.qihe.study.ClientTest - start id = 14 and then it hang! after start id = 9 it hanged too! After a while it said could not connect
Re: Question about the mina SocketConnector
Hi steve, Thank you for your reply. I see someone used ten or more connections to send large amount of data, but it is blocking socket. Should I use more connections? Regards QiHe On Wed, Apr 23, 2008 at 8:50 PM, Steve Johns [EMAIL PROTECTED] wrote: Yes, you can. On Mon, Apr 21, 2008 at 11:17 PM, Michael Qi [EMAIL PROTECTED] wrote: Hi, Could I use SocketConnector send large amount of messages? Thank you QiHe
Re: the client can not receive the response message from the mina server
Thanks Steve. Steve Johns-2 wrote: Client and server send the some message to each other in a certain time period and make sure the other side is still alive. On Dec 27, 2007 1:49 PM, Qi [EMAIL PROTECTED] wrote: Hi Steve, Would you mind explain a bit more on heartbeat ? Cheers, Qi Steve Johns-2 wrote: Most likely, either client or server didn't detect the disconnection. Please use heartbeat. On Dec 26, 2007 11:05 PM, hefm [EMAIL PROTECTED] wrote: can you help me ? i develop a socket server based on the MINA, all the client send the request message to the server ,the server will send the response message to the client , but after run some days , when the client send the message to the server ,the client can not receive the response message from the server ,but the server logs display the server write the response to the response buffer, why the client can not receive the message ? -- View this message in context: http://www.nabble.com/the-client-can-not-receive-the-response-message-from-the-mina-server-tp14503254s16868p14509885.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.comhttp://nabble.com/ . -- View this message in context: http://www.nabble.com/the-client-can-not-receive-the-response-message-from-the-mina-server-tp14503254s16868p14553757.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: Using a bunch of connections in a client?
Hi there, I used to confused on the same problem as well, so please let me share my understanding on this. You would only need on IoConnector if you only need one set of business logic for handling server's response. Let's image your IoConnector is your web browser, and IoAcceptor is a remote website. You can use one browser to connect to many website or open many pages of one website at the same time. (The more browsers you open, the more resource gets consumed.) Every time when you call IoConnector.connect(), an IoSession is created. Just like your web browser opens a page to a website, your browser and the remote server need to maintain a HttpSession. All further request to the same website(IoAcceptor) can all share this session. Depends on the class of your protocol (stateful- you store things in the session | stateless - nothing gets stored ), you can choose to create a different IoSession for each working thread, or just let all the working threads share a common one. IoSession is thread-safe, simultaneous calls would effect each other. It's recommended to have an ExectorFilter before your IoHandler if methods in the handler need to do I/O operations(database accessing, socket operation, etc time consuming tasks). Wish this would help you. Cheers, Qi stork wrote: I'm not sure I understand - how can a SocketConnector create more than one connection? That would explain why the connections aren't getting close properly. Maarten Bosteels wrote: Hello Alex, 1) you can use one SocketConnector to create many connections 2) search the forum for Too many open files This thread might interest you: http://www.nabble.com/Too-many-open-files-to7521146s16868.html HTH Maarten On Dec 27, 2007 4:43 PM, stork [EMAIL PROTECTED] wrote: Hi, I'm trying to write a client that can utilize a set number of connections using MINA trunk (mina-core-2.0.0-M1-20071221.061156-110.jar). I'm using the netcat (http://svn.apache.org/viewvc/mina/trunk/example/src/main/java/org/apache/mina/example/netcat/Main.java?view=markup) as an example but I think I'm doing it wrong. I've never used NIO before so this is all a bit confusing to me. What's the preferred way of managing a lot of nio client connections using MINA? At the moment I'm just creating a lot of NioSocketConnector objects, and connecting them. I have added an IoFutureListener to the ConnectFuture obtained by calling nioSocketConnector.connect(InetSocketAddress): public void operationComplete(IoFuture arg0) { if(arg0 instanceof ConnectFuture) { ConnectFuture cf = (ConnectFuture)arg0; debug(connected=+cf.isConnected()+,exc=+cf.getException()); if(cf.isConnected()) { /** * Add the connected client to the clients queue for processing */ boolean offered = clients.offer((TyrClient)cf.getSession().getAttribute(CLIENT)); if(!offered) throw new RuntimeException(Couldn't offer connected client.); } else { /** * Add a new connection attempt to the connection queue. */ boolean offered = pending.offer(createNewConnection(TIMEOUT)); if(!offered) throw new RuntimeException(Couldn't offer connection.); } } } And I'm getting a lot of this: [T:NioSocketConnector-75] connected=false,exc=java.net.ConnectException: Connection refused [T:NioSocketConnector-76] connected=false,exc=java.net.ConnectException: Connection refused [T:NioSocketConnector-77] connected=false,exc=java.net.ConnectException: Connection refused (Which is being expected since I'm just connecting to a closed port) and then, 7693 [NioSocketConnector-77] WARN org.apache.mina.common.DefaultExceptionMonitor - Unexpected exception. org.apache.mina.common.RuntimeIoException: Failed to initialize. at org.apache.mina.common.AbstractPollingIoConnector.init(AbstractPollingIoConnector.java:103) at org.apache.mina.common.AbstractPollingIoConnector.init(AbstractPollingIoConnector.java:61) at org.apache.mina.transport.socket.nio.NioSocketConnector.init(NioSocketConnector.java:52) at tyr.Client.createNewConnection(RickRoller.java:46) at tyr.Client.operationComplete(RickRoller.java:154) at org.apache.mina.common.DefaultIoFuture.notifyListener(DefaultIoFuture.java:302) at org.apache.mina.common.DefaultIoFuture.notifyListeners(DefaultIoFuture.java:287) at org.apache.mina.common.DefaultIoFuture.setValue
Re: the client can not receive the response message from the mina server
Hi Steve, Would you mind explain a bit more on heartbeat ? Cheers, Qi Steve Johns-2 wrote: Most likely, either client or server didn't detect the disconnection. Please use heartbeat. On Dec 26, 2007 11:05 PM, hefm [EMAIL PROTECTED] wrote: can you help me ? i develop a socket server based on the MINA, all the client send the request message to the server ,the server will send the response message to the client , but after run some days , when the client send the message to the server ,the client can not receive the response message from the server ,but the server logs display the server write the response to the response buffer, why the client can not receive the message ? -- View this message in context: http://www.nabble.com/the-client-can-not-receive-the-response-message-from-the-mina-server-tp14503254s16868p14509885.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: support for asyncrhonous messaging on a per-connection basis
Hi there, I believe that every time a connection is built, there's a session being created with it. So per-connection based protocol is really just a special case of per-session protocol. If you don't expect the server to send you any response, you may do something like code WriteFuture wf = session.write(Message msg); wf.join(); CloseFuture cf = session.close(); cf.join(); /code to close the session and connection after you finish sending you message. Alternatively, You can add a IoFutureListener, which will be notified once a IoFuture's status is changed, to close the session. If you do expect the server to send some response message, you can do the same thing in the IoHandler you give to your IoConnector. In which case, you would have to use IoFutureListener in order to avoid deadlock. Cheers, Qi scottmiller wrote: I saw this in another posting: And, if your client sends messages asynchronously (i.e. sends requests before all previous responses are received.), any incoming messages will be buffered in the internal queue until your messageReceived() method returns. The queue is maintained on a per-session basis, so any other sessions won't be affected when one session's messageReceived() runs long. Are there plans in an upcoming MINA release to support asynchronous messaging on a per-connection basis? Any known workarounds? -- View this message in context: http://www.nabble.com/support-for-asyncrhonous-messaging-on-a-per-connection-basis-tp14463996s16868p14475983.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: How can i improve the total numbers of session which server will handle connects from client
Hi, Can you try to print the exception stack trace in the exceptionCaught() method of your client-side codes, or attach the source codes of how you configure your connector and acceptor? Cheers, Qi chinadeng wrote: thanks your reply very much; It is strongly improve the throughput of the server,when i reset the SocketAcceptorConfig blacklog parameter . The problem is still exst.when 300 clients connect ,10clients will be refused,can not connect successfuly; how can i do it now?? -- View this message in context: http://www.nabble.com/How-can-i-improve-the-total-numbers-of-session-which-server-will--handle-connects-from-client-tp14429723s16868p14447183.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: How can i improve the total numbers of session which server will handle connects from client
Hi, For those clients failed establish a connection, do they report any errors such as connection timeout, etc? I've run a simple experiment that tries to establish 300 connections to the example sumupserver running on another machine in the local network, and I found no problem. However, my client code is in Java, so it is different from your situation. And could you also remove the threadmodel settings and set it to be Thread.manual, then increase the receiver buffer size in SocketAcceptorConfig.getSessionConfig().setReceiveBufferSize(), just for a experiment? Cheers, Qi -- View this message in context: http://www.nabble.com/How-can-i-improve-the-total-numbers-of-session-which-server-will--handle-connects-from-client-tp14429723s16868p14449315.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: WriteFuture.join() hangs when called in IoHandler.sessionOpened() in Datagram transport.
Hi Trustin, Thanks a lot, I have taken the IoFutureListener approach. Btw, It's a real flexible and good design to have all these listeners. Cheers, Qi Trustin Lee wrote: Hi Qi, It's not a bug but a kind of dead lock caused by misuse of the API. You are usually not supposed to call IoFuture.join() within an IoHandler because the IoHandler methods might be being executed in the same thread with the I/O processor thread. You wrote something and you call join() to wait for the I/O processor thread to finish the write operation in the I/O processor thread, then join() won't return at all. MINA 2 detects this kind of situation automatically and emits advisory exception, but it's not in MINA 1.x unfortunately. The alternative to join() is adding an IoFutureListener. HTH, Trustin On Dec 17, 2007 4:48 PM, Qi [EMAIL PROTECTED] wrote: Hi there, I've just found a possible bug in MINA Datagram transport. In my handler class, I was trying to write some messages once the sessionOpened event is fired, while the program will hang if I get the writeFuture and call join() on it. If I call join with a timeout parameter, after the operation gets timeout, WriteFuture.isWritten returns false. (Same senario would go through if it's via SocketConnector transport, as showing in the sumup example.) However, if I don't place the write operation inside sessionOpened(); instead, I placed they after DatagramConnector.connect(), then writes will successfully go though. I'm using MINA 1.1.5 and JRE 1.6. Source code that demostrate the problem is attached. http://www.nabble.com/file/p14370126/BroadcastSender.java BroadcastSender.java -- View this message in context: http://www.nabble.com/WriteFuture.join%28%29-hangs-when-called-in-IoHandler.sessionOpened%28%29-in-Datagram-transport.-tp14370126s16868p14370126.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com. -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6 -- View this message in context: http://www.nabble.com/WriteFuture.join%28%29-hangs-when-called-in-IoHandler.sessionOpened%28%29-in-Datagram-transport.-tp14370126s16868p14430072.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: How can i improve the total numbers of session which server will handle connects from client
Hi there, Have you tried setting a higher value for backlog yet? It's a parameter that you can tune around with in SocketAcceptorConfig, which determines how many incoming TCP connections your underlying system would try to queue up if no enough resources can be allocated to handle these connection requests. If such a limit is reached, further requests could be dropped. Since you mentioned connection requests were arriving in a small time frame, I have a strong feeling this parameter is the cause. Please See Note about socket backlogs section on this page for more details. http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpServer.html Cheers, Qi chinadeng wrote: server can not detect the 60 connections,not session closed(session is not opened at all), in other word ,when 300 clients connect ,server only can hanlder parts of clients(not all clients) Trustin Lee wrote: What do you mean by 'discarded'? Are the 60 connections get closed? Are you notified with sessionOpened or sessionClosed? Trustin On Dec 20, 2007 11:48 AM, chinadeng [EMAIL PROTECTED] wrote: Hi: when 300 client connect to my servers at almost in same time ,but the server only can handle 240 client ,60 client will be discarded. my server codes like fellowing : InetSocketAddress serverAddress1 = new InetSocketAddress(8008); DemuxingProtocolCodecFactory dpcf = new DemuxingProtocolCodecFactory(); dpcf.register(new CliEntCmdDeconder()); dpcf.register(new CliEntEncoder()); SocketAcceptor acceptor = new SocketAcceptor(Runtime.getRuntime().availableProcessors() + 1, Executors.newCachedThreadPool()); SocketAcceptorConfig cfg = new SocketAcceptorConfig(); cfg.setReuseAddress(true); DefaultIoFilterChainBuilder chain = cfg.getFilterChain(); chain.addLast(logger, new LoggingFilter()); chain.addLast(protocol, new ProtocolCodecFilter(dpcf)); System.out.println(long on ); DemuxingIoHandler iohanlder=new DemuxingIoHandler(); iohanlder.addMessageHandler(clicmdbro.class, new CliEntCmdHandler(testb)); try { acceptor.bind(serverAddress1,iohanlder, cfg); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } how can i ressolve the problem?? Thanks in Advance -- View this message in context: http://www.nabble.com/How-can-i-improve-the-total-numbers-of-session-which-server-will--handle-connects-from-client-tp14429723s16868p14429723.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com. -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6 -- View this message in context: http://www.nabble.com/How-can-i-improve-the-total-numbers-of-session-which-server-will--handle-connects-from-client-tp14429723s16868p14431567.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
WriteFuture.join() hangs when called in IoHandler.sessionOpened() in Datagram transport.
Hi there, I've just found a possible bug in MINA Datagram transport. In my handler class, I was trying to write some messages once the sessionOpened event is fired, while the program will hang if I get the writeFuture and call join() on it. If I call join with a timeout parameter, after the operation gets timeout, WriteFuture.isWritten returns false. (Same senario would go through if it's via SocketConnector transport, as showing in the sumup example.) However, if I don't place the write operation inside sessionOpened(); instead, I placed they after DatagramConnector.connect(), then writes will successfully go though. I'm using MINA 1.1.5 and JRE 1.6. Source code that demostrate the problem is attached. http://www.nabble.com/file/p14370126/BroadcastSender.java BroadcastSender.java -- View this message in context: http://www.nabble.com/WriteFuture.join%28%29-hangs-when-called-in-IoHandler.sessionOpened%28%29-in-Datagram-transport.-tp14370126s16868p14370126.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: Problem when use ObjectSerializationCodecFactory in Datagram broadcasting between linux and window
Hi Trustin, I will upload the source files as a eclipse project archive. The archive includes mina-core1.1.5 and slf4j jar files, so it should be able to start with no extra settings. I've also uploaded it to: http://www.cs.mu.oz.au/~caoq/mina-broadcasting.zip Just in case if you have problem download if from the forum. Please feel free to modify the codes or show others as a bad example of using mina :) Cheers, http://www.nabble.com/file/p14326975/mina-broadcasting.zip mina-broadcasting.zip Qi Cao 14. Dec 2007 Trustin Lee wrote: Hi Qi, Such a small object should be fine I guess. Could you provide us full source code so we can test? Trustin -- View this message in context: http://www.nabble.com/Problem-when-use-ObjectSerializationCodecFactory-in-Datagram-broadcasting-between-linux-and-window-tp14311279s16868p14326975.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: Problem when use ObjectSerializationCodecFactory in Datagram broadcasting between linux and window
Hi Trustin, For some reason that I don't know, messages are now transferred successfully. I've done nothing except my windows machine was rebooted. Truly lost... Qi Cao 14 Dec 2007 Qi wrote: Hi Trustin, I will upload the source files as a eclipse project archive. The archive includes mina-core1.1.5 and slf4j jar files, so it should be able to start with no extra settings. I've also uploaded it to: http://www.cs.mu.oz.au/~caoq/mina-broadcasting.zip Just in case if you have problem download if from the forum. Please feel free to modify the codes or show others as a bad example of using mina :) Cheers, http://www.nabble.com/file/p14326975/mina-broadcasting.zip mina-broadcasting.zip Qi Cao 14. Dec 2007 Trustin Lee wrote: Hi Qi, Such a small object should be fine I guess. Could you provide us full source code so we can test? Trustin -- View this message in context: http://www.nabble.com/Problem-when-use-ObjectSerializationCodecFactory-in-Datagram-broadcasting-between-linux-and-window-tp14311279s16868p14327326.html Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Problem when use ObjectSerializationCodecFactory in Datagram broadcasting between linux and window
Hi there, I was writing some prototype codes that uses MINA to broadcast some message in a heterogeneous network. For simplicity and fast development time, I used ObjectSerializationEncoder/Decoder. Somehow, a exception was occurred when sending messages(serializable object) between a windows machine and a linux machine. (detailed exception stack trace is attached at the end of this post.) Messages sent from windows to windows boxes are fine. Plain strings between windows and Linux also been received normally. I just wonder if anyone has met this problem before? Thanks in advance, Qi 13 Dec. 2007 I'm using MINA 1.1.5. The windows machine has windows XP SP2 (32bit), JRE 1.6.0 installed. The Linux machine has fedora 5 (Linux version 2.6.20-1.2320.fc5) and JRE 1.6.0. Here's the full stack trace: ExpiringMapExpirer-1 [INFO ] [/192.168.1.100:3207] CLOSE - mina.BroadcastReceiver$1 ExpiringMapExpirer-1 [INFO ] [/192.168.1.100:3207] CLOSED - mina.BroadcastReceiver$1 session closed DatagramAcceptor-0 [INFO ] [/192.168.1.21:33435] CREATED - mina.BroadcastReceiver$1 session created DatagramAcceptor-0 [INFO ] [/192.168.1.21:33435] OPENED - mina.BroadcastReceiver$1 DatagramAcceptor-0 [INFO ] [/192.168.1.21:33435] RECEIVED: HeapBuffer[pos=0 lim=106 cap=128: 00 00 00 66 AC ED 00 05 73 72 00 27 62 6F 6F 2E 63 6F 6D 6D 6F 6E 73 2E 63 61 63 68 65 2E 65 76 65 6E 74 2E 4D 6F 63 6B 59 6F 6F 62 65 72 45 76 65 6E 74 78 72 00 2B 62 6F 6F 2E 63 6F 6D 6D 6F 6E 73 2E 63 61 63 68 65 2E 65 76 65 6E 74 2E 41 62 73 74 72 61 63 74 59 6F 6F 62 65 72 45 76 65 6E 74 78 70 74 00 03 31 32 33] - mina.BroadcastReceiver$1 DatagramAcceptor-0 [WARN ] [/192.168.1.21:33435] EXCEPTION: - mina.BroadcastReceiver$1 org.apache.mina.filter.codec.ProtocolDecoderException: org.apache.mina.common.BufferDataException: java.io.EOFException (Hexdump: empty) at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:164) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) at org.apache.mina.filter.LoggingFilter.messageReceived(LoggingFilter.java:89) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived(AbstractIoFilterChain.java:499) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(AbstractIoFilterChain.java:293) at org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate.readSession(DatagramAcceptorDelegate.java:400) at org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate.processReadySessions(DatagramAcceptorDelegate.java:368) at org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate.access$1200(DatagramAcceptorDelegate.java:61) at org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate$Worker.run(DatagramAcceptorDelegate.java:320) at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51) at java.lang.Thread.run(Unknown Source) Caused by: org.apache.mina.common.BufferDataException: java.io.EOFException at org.apache.mina.common.ByteBuffer.getObject(ByteBuffer.java:1530) at org.apache.mina.filter.codec.serialization.ObjectSerializationDecoder.doDecode(ObjectSerializationDecoder.java:92) at org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtocolDecoder.java:133) at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:157) ... 16 more Caused by: java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source) at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(Unknown Source) at java.io.ObjectInputStream$BlockDataInputStream.readUTF(Unknown Source) at java.io.ObjectInputStream.readUTF(Unknown Source) at java.io.ObjectStreamClass.readNonProxy(Unknown Source) at java.io.ObjectInputStream.readClassDescriptor(Unknown Source) at org.apache.mina.common.ByteBuffer$3.readClassDescriptor(ByteBuffer.java:1516) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source
Re: Problem when use ObjectSerializationCodecFactory in Datagram broadcasting between linux and window
Hi Trustin, Thank you for the quick reply. The Object was actually quite small, I've also tried with a new Integer(123) but the same exception would still happen. Is there any workarounds that can re-organize UDP packets received with MINA? I've done a search in the forum, and found there isn't many posts about broadcasting. Do you have any examples about sending datagram using MINA at hand that I can have a look? Very much appreciated, Qi Trustin Lee wrote: I think your message doesn't fit into one UDP packet, which mean your message is truncated. It can always happen in UDP if you are sending a relatively big object. HTH, Trustin On Dec 13, 2007 4:37 PM, Qi [EMAIL PROTECTED] wrote: Hi there, I was writing some prototype codes that uses MINA to broadcast some message in a heterogeneous network. For simplicity and fast development time, I used ObjectSerializationEncoder/Decoder. Somehow, a exception was occurred when sending messages(serializable object) between a windows machine and a linux machine. (detailed exception stack trace is attached at the end of this post.) Messages sent from windows to windows boxes are fine. Plain strings between windows and Linux also been received normally. I just wonder if anyone has met this problem before? Thanks in advance, Qi 13 Dec. 2007 The windows machine has windows XP SP2 (32bit), JRE 1.6.0 installed. The Linux machine has fedora 5 (Linux version 2.6.20-1.2320.fc5) and JRE 1.6.0. Here's the full stack trace: ExpiringMapExpirer-1 [INFO ] [/192.168.1.100:3207] CLOSE - mina.BroadcastReceiver$1 ExpiringMapExpirer-1 [INFO ] [/192.168.1.100:3207] CLOSED - mina.BroadcastReceiver$1 session closed DatagramAcceptor-0 [INFO ] [/192.168.1.21:33435] CREATED - mina.BroadcastReceiver$1 session created DatagramAcceptor-0 [INFO ] [/192.168.1.21:33435] OPENED - mina.BroadcastReceiver$1 DatagramAcceptor-0 [INFO ] [/192.168.1.21:33435] RECEIVED: HeapBuffer[pos=0 lim=106 cap=128: 00 00 00 66 AC ED 00 05 73 72 00 27 62 6F 6F 2E 63 6F 6D 6D 6F 6E 73 2E 63 61 63 68 65 2E 65 76 65 6E 74 2E 4D 6F 63 6B 59 6F 6F 62 65 72 45 76 65 6E 74 78 72 00 2B 62 6F 6F 2E 63 6F 6D 6D 6F 6E 73 2E 63 61 63 68 65 2E 65 76 65 6E 74 2E 41 62 73 74 72 61 63 74 59 6F 6F 62 65 72 45 76 65 6E 74 78 70 74 00 03 31 32 33] - mina.BroadcastReceiver$1 DatagramAcceptor-0 [WARN ] [/192.168.1.21:33435] EXCEPTION: - mina.BroadcastReceiver$1 org.apache.mina.filter.codec.ProtocolDecoderException: org.apache.mina.common.BufferDataException: java.io.EOFException (Hexdump: empty) at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:164) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) at org.apache.mina.filter.LoggingFilter.messageReceived(LoggingFilter.java:89) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived(AbstractIoFilterChain.java:499) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(AbstractIoFilterChain.java:293) at org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate.readSession(DatagramAcceptorDelegate.java:400) at org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate.processReadySessions(DatagramAcceptorDelegate.java:368) at org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate.access$1200(DatagramAcceptorDelegate.java:61) at org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate$Worker.run(DatagramAcceptorDelegate.java:320) at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51) at java.lang.Thread.run(Unknown Source) Caused by: org.apache.mina.common.BufferDataException: java.io.EOFException at org.apache.mina.common.ByteBuffer.getObject(ByteBuffer.java:1530) at org.apache.mina.filter.codec.serialization.ObjectSerializationDecoder.doDecode(ObjectSerializationDecoder.java:92) at org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtocolDecoder.java:133) at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived
Re: Multi-thread/single-session and multi-thread/multi-session, which performances better?
Hi Trustin, Thank you for your quick reply. Sorry I think I didn't make myself clear, I was intend to ask which model is better for the client side. Since the clients are going to run many threads, will that cause performance issue if all of them are going to share just one IoSession? Looking forward to see 2.0's release :) Thanks again, Qi Trustin Lee wrote: Hi Qi, On Dec 6, 2007 12:17 PM, Qi [EMAIL PROTECTED] wrote: Hi there, I'm looking to write a client-server application which has a multi-threaded client (2500+ threads per client). Each thread needs to send and receive messages with the server, though the sending frequency is pretty low(2-3 messages(of 1k bytes each) per minute per thread). I just wonder which thread-ioSession mapping model would suit this scenario better? It doesn't depend on the number of clients but depends on what your IoHandler does. If it doesn't interact with any other backends such as database which take time, then you are safe to remove all ExecutorFilters and disable ThreadModel. Otherwise, you will need at least one ExecutorFilter. I'm looking to start this component with MINA 2.0, could you please also suggest a consider-to-be-stable revision ? I can't. I want to start a vote for releasing the first milestone though. HTH, Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6 -- View this message in context: http://www.nabble.com/Multi-thread-single-session-and-multi-thread-multi-session%2C-which-performances-better--tf4953785s16868.html#a14203520 Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: sending/receiving a byte[]
Hi Aquafina, I'm not a MINA expert, but as far as I know, you can wrap a byte array into ByteBuffer by using ByteBuffer.wrap(byte[] byteArray, int offset, int length), and send it through IoSession.write(the ByteBuffer instance); Please be aware that by doing this, you bypass your costumized ProtocalEncoder/Decoder. Wrap a byte array into a serilizable object, just in sake of sending it alone, is a bit redundant IMHO. The wrap object will need to go through ObjectSerializationDecoder and ObjectSerializationEncoder, which add some extra cost. Cheers, Qi aquafina wrote: Hello, I am new with MINA. Would anyone please show me how to configure SocketAcceptorConfig to receive/send a byte[]. I tried to wrap it with a Serializable object and used cfg.getFilterChain().addLast( codec, new ProtocolCodecFilter( new ObjectSerializationCodecFactory())); but it doesn't seem to work. Thanks, -- View this message in context: http://www.nabble.com/sending-receiving-a-byte---tf4958040s16868.html#a14203971 Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Multi-thread/single-session and multi-thread/multi-session, which performances better?
Hi there, I'm looking to write a client-server application which has a multi-threaded client (2500+ threads per client). Each thread needs to send and receive messages with the server, though the sending frequency is pretty low(2-3 messages(of 1k bytes each) per minute per thread). I just wonder which thread-ioSession mapping model would suit this scenario better? I'm looking to start this component with MINA 2.0, could you please also suggest a consider-to-be-stable revision ? Cheers, Qi -- View this message in context: http://www.nabble.com/Multi-thread-single-session-and-multi-thread-multi-session%2C-which-performances-better--tf4953785s16868.html#a14185627 Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.