Le 31/07/2014 03:41, Carlos Alegria Galicia a écrit :
> Hi everyone,
>
> I developed a MINA based client and server to send files over a TCP
> connection. I am using MINA 2.0.7 on both.
>
>    - In the client I am sending the file using a header to send file
>    properties and FileRegion to actually stream the file.
>    - In the server I created a Filter to read the header, and then receive
>    and locally store the file content 'till the expected number of bytes are
>    received.
>
> My problem is that, intermittently, I am not able to receive the last chunk
> of data from the client. By debugging, I found out that the last chunk is
> actually always shorter than the receive buffer in the server. Is it
> possible that I am not receiving this last chunk because the
> Filter.messageReceived() method is not called on my filter because the
> buffer is not completely filled with data? 

No. As soon as 1 single byte of data is received, a messageReceived
event is generated (but usually, you will get more than 1 byte : you get
as much data as the socket.read() gave).

You have most certainly some other problem, like your own code is not
calling your handler when it receives less that what the buffer you are
storing the incoming data is expected to hold.

It's hard to tell without having the entire code of your server.

Another possibility is that the client is faulty. Are you sure
everything is correctly sent ? At this point, it's a possibility that
the code that manage FileRegion is faulty. A code that reproduces the
problem could help debugging MINA.

At this point, I would suggest you add a Logger Filter to see if you get
everything on the server side, and that you emit everything on the
client side.

On my side, I can double check the FileRegion handling in MINA, to be sure.


Reply via email to