Hello! The reason was, that requests' and/or responses' bodies did not have empty line at the end of body data, TextLineCodecFactory (i think logically) did not parse them. I ended up adding newline to the client's request and to backend server's response. Everything works just fine now, thanks for your assistance! Marek
2014-10-31 9:18 GMT+01:00 Marek Sedlak <[email protected]>: > I am doing it myself; this way I initialize the TCP server: > > ----------------------------------------- > // acceptor init + chain ref > TCPServer.acceptor = new NioSocketAcceptor(); > DefaultIoFilterChainBuilder chain = acceptor.getFilterChain(); > > // ssl support > if (ControllerConfig.getInstance().isTcpSsl()){ > SslFilter sslFilter = new > SslFilter(ControllerSslContextFactory.getInstance(true)); > chain.addLast("sslFilter", sslFilter); > } > > // logger > chain.addLast( "logger", new LoggingFilter() ); > > // codecfilter > chain.addLast( "codec", new ProtocolCodecFilter( new TextLineCodecFactory( > Charset.forName( "UTF-8" )))); > > // assign handler > acceptor.setHandler( new TCPHandler() ); > > // config > acceptor.getSessionConfig().setReadBufferSize( 4096 ); > acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, IDLE_PERIOD > ); > > // start! > acceptor.bind( new InetSocketAddress(port) ); > ----------------------------------------- > > > then after I do http request from the client, on the instance of > TCPHandler the overriden method "messageReceived" gets called one by one > with each the line of the request HOWEVER it ends up after the headers, the > body never gets here, I have no clue why. maybe the body should end with > \r\n -- that's why (?) > > thanks a million! > Marek > > 2014-10-30 18:36 GMT+01:00 Emmanuel Lécharny <[email protected]>: > >> Le 30/10/14 18:13, Marek Sedlak a écrit : >> > Hello! >> Hi, >> > I have implemented tcp server based on apache mina. it holds tcp >> > connections and communicate vice versa with clients. now i need to >> > implement acceptor the way it accepts data using TextLineCodecFactory >> but >> > at the same time it can read http request and resend it, then the reply >> > pass back to the session. >> > >> > i have implemented that after "messageReceived" i just put messages into >> > string with \r\n, then in the end i have plain http request. I send it >> to >> > the server, server replies, I receive reply and send it to the initial >> > connection from client. This is some kind of proxy server. >> > >> > Now everything works EXCEPT that when I receive either message from >> client >> > or from http server (the last phase) and request/response has >> > content-length higher than 0 (request with post/patch and/or the usual >> > response) I will end up where HTTP headers end, no matter what I do, I >> just >> > do not get the BODY itself, >> >> I suspect you are dealing with the content of your messages yourself, am >> I right ? Or are you using teh MINA HTTP codec ? >> >> >> >> > > > -- > If an experiment works, something has gone wrong :P > -- If an experiment works, something has gone wrong :P
