[ 
https://issues.apache.org/jira/browse/DIRMINA-419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Emmanuel Lecharny closed DIRMINA-419.
-------------------------------------

    Resolution: Fixed

2 years old issue, 5 versions ago... Let's close it.

> about the Proxy example
> -----------------------
>
>                 Key: DIRMINA-419
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-419
>             Project: MINA
>          Issue Type: Bug
>          Components: Example
>    Affects Versions: 1.1.2
>            Reporter: im-james
>
> I've been using the proxy example and I've discovered a bug.
> The IOHandler that handles the communication with the server (proxy 
> <---->server) I've found a situation where the handler receives a 
> messageReceived event and then a sessionClosed event in a very short time 
> period. The result is that the bytes received in the proxy are not sent to 
> the client. The connection to the client is closed before the message had a 
> chance to be written.
> It is hard to explain the problem so here is a log trace showing what happens 
> when everything goes well:
> 12:36:05,429 DEBUG [SocketAcceptorIoProcessor-0.0] 
> connectionProxy.ClientToProxyIoHandler - [/127.0.0.1:14784] sessionOpened
> 12:36:05,461 DEBUG [SocketAcceptorIoProcessor-0.0] 
> connectionProxy.ClientToProxyIoHandler - [/127.0.0.1:14784] messageReceived 8
> 12:36:05,461 DEBUG [Thread-1] connectionProxy.test.TestAppServer - server has 
> received and sent data back
> 12:36:05,461 DEBUG [AnonymousIoService-7] 
> connectionProxy.ServerToProxyIoHandler - [/127.0.0.1:80] messageSent 8
> 12:36:05,461 DEBUG [AnonymousIoService-7] 
> connectionProxy.ServerToProxyIoHandler - [/127.0.0.1:80] messageReceived 8
> 12:36:05,461 DEBUG [SocketAcceptorIoProcessor-0.0] 
> connectionProxy.ClientToProxyIoHandler - [/127.0.0.1:14784] messageSent 8
> 12:36:05,461 DEBUG [AnonymousIoService-7] 
> connectionProxy.ServerToProxyIoHandler - [/127.0.0.1:80] sessionClosed   0
> 12:36:05,461 DEBUG [SocketAcceptorIoProcessor-0.0] 
> connectionProxy.ClientToProxyIoHandler - [/127.0.0.1:14784] sessionClosed
> 12:36:05,461 DEBUG [Thread-5] connectionProxy.test.TestClient - client has 
> received the data
> And this is a log trace that shows the problem:
> 12:38:00,554 DEBUG [SocketAcceptorIoProcessor-0.0] 
> connectionProxy.ClientToProxyIoHandler - [/127.0.0.1:14904] sessionOpened
> 12:38:00,570 DEBUG [SocketAcceptorIoProcessor-0.0] 
> connectionProxy.ClientToProxyIoHandler - [/127.0.0.1:14904] messageReceived 8
> 12:38:00,586 DEBUG [Thread-1] connectionProxy.test.TestAppServer - server has 
> received and sent data back
> 12:38:00,586 DEBUG [AnonymousIoService-12] 
> connectionProxy.ServerToProxyIoHandler - [/127.0.0.1:80] messageSent 8
> 12:38:00,586 DEBUG [AnonymousIoService-12] 
> connectionProxy.ServerToProxyIoHandler - [/127.0.0.1:80] messageReceived 8
> 12:38:00,586 DEBUG [AnonymousIoService-12] 
> connectionProxy.ServerToProxyIoHandler - [/127.0.0.1:80] sessionClosed   0
> 12:38:00,586 DEBUG [SocketAcceptorIoProcessor-0.0] 
> connectionProxy.ClientToProxyIoHandler - [/127.0.0.1:14904] sessionClosed
> java.io.EOFException
>       at java.io.DataInputStream.readFully(DataInputStream.java:178)
>       at java.io.DataInputStream.readLong(DataInputStream.java:380)
>       at com.indeos.connectionProxy.test.TestClient.run(TestClient.java:58)
>       at java.lang.Thread.run(Thread.java:595)        
> The EOFException says that the client has not be able to read the data before 
> the connection was closed.
> The conclusion is that the close can happen before the write. Thus to solve 
> the issue I had to add a join() in the messageReceived method such as:
> ((IoSession) session.getAttachment()).write(wb).join();
> Of course with this solution I break the asynchronous nature of the proxy. If 
> you know a better solution I'd like to hear it!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to