You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Nitin Phuria <ni...@integramicro.com.INVALID> on 2024/10/24 06:23:57 UTC
MINA: Messages writen to session are not getting written to TCP/IP and writeQueue count is increasing
Dear All,
We have developed one server using Apache MINA V2.1.6 where multiple
vendors connect and send the messages which needs to be processed and then
response have to be sent back to vendor. Currently we have put a strategy
that vendor has to send one message per connection and after getting
response or timeout vendor has to close the connection.
We also have persistance connection open from our MINA based server
with third party server whcih is tcp/ip channel and for each vendor request
we get we have to send the received message to this third party server. Past
3-4 days we have observed that application works fine for some time and then
suddenly all the messages written to session.write method does not go to
TCP/Ip and no Message sent event is generated for them. When I checked the
session's getWriteRequestQueue().size() it is observed that it is
continuously increasing only.
This operation is asynchronous; IoHandler.messageSent(IoSession, Object)
will be invoked when the message is actually sent to remote peer. In our
observation we found that the messageSent was not called once we observe the
WriteRequestQueue(). Size started building up.
When we checked with third party server they told they are not receiving any
messages on the port where we have opened persistence connection and they
are listening on it.
Any possible checks that we need to do at OS level or Network level which
can give us lead for the problem will help. If we restart our Server then
again for sometime it will work and then same problem of WriteQueue size
build up will start.
We have our own ProtocolCodecFactory implemented is used for
endocing/decoding messages from our server to third party server.
We have no executorFilter in the chain.
Below is my Protocol Encoder class
public class DefaultMyMsgEncoder extends ProtocolEncoderAdapter
{
public DefaultMyMsgEncoder()
{
}
public void encode(IoSession session, Object msg, ProtocolEncoderOutput
out) throws Exception
{
MyMsg myMsg = (MyMsg) msg;
IoBuffer buffer =
IoBuffer.allocate(myMsg.getLengthBytes().length+myMsg.getMsgBytes().length
);
buffer.put(myMsg.getLengthBytes());
buffer.put(myMsg.getMsgBytes());
buffer.flip();
out.write(buffer);
}
}
Thanks in advance.
Thanks And Regards,
Nitin Phuria
--
*
*
*Confidentiality Disclaimer**: "The information contained in this
electronic message
(email) and any attachments to this email are intended
for the exclusive use of
the addressee(s) and access to this email by
anyone else is unauthorized. The
email may contain proprietary,
confidential or privileged information or
information relating to Integra
Group. If you are not the intended recipient,
please notify the sender by
telephone, fax, or return email and delete this
communication and any
attachments thereto, immediately from your computer. Any
dissemination,
distribution, or copying of this communication and the
attachments thereto
(in whole or part), in any manner, is strictly prohibited
and actionable at
law. The recipient acknowledges that emails are susceptible
to alteration
and their integrity cannot be guaranteed and that Company does
not
guarantee that any e-mail is virus-free and accept no liability for any
damage caused by any virus transmitted by this email."*
Re: MINA: Messages writen to session are not getting written to TCP/IP and writeQueue count is increasing
Posted by Emmanuel Lécharny <el...@gmail.com>.
On 25/10/2024 07:43, Nitin Phuria wrote:
> Hi,
>
> Thanks for your quick response with few points to check.
>
> We are not getting any sessionClosed or exceptionCaught event on this session.
>
> We have also checked at OS level with netstat and could see that session was available with ESTABLISHED state
>
> Also before sending any message we have below check and if this is true then only we write the message to session
>
> if (session() != null && session().isConnected())
That does not mean the actual connection is still up. It gives you a
status of the session, not a status of the connection.
>
> Pls let me know whether this above check is sufficient to assume that session is not bad and it is good to write to this session.
You should assume that if you haven't receive a messageSent event when
you do a write, then you have an issue.
>
> Also we want to understand if we are writing say 10 messages one after another to session then they will be queued up to be written to session as single thread will be doing this job. For some reason if this writing to session is failed then will it skip the current message and take up next message to write? As I understand the Codec Encoder will be called for this operation. Any error in ProtocolEncoder will have any impact if one of the message it fails to write to session.
Keep in mind that MINA is managing asynchronous operations. If the
remote peer is not capable of reading data for any reason, then when the
socket buffer is full, you won't be able to write any more data into it.
That means those messages/data will remain in a queue.
It's absolutely critical to check that any message being written has
been actually written (ie a messageSent event has been received),
otherwise you'll blow your client. This is also a typicl situation where
a slow reader might crash your client.
>
> Thanks And Regards,
> Nitin Phuria
>
> -----Original Message-----
> From: Emmanuel Lécharny [mailto:elecharny@gmail.com]
> Sent: 24 October 2024 23:34
> To: Nitin Phuria; users@mina.apache.org
> Subject: Re: MINA: Messages writen to session are not getting written to TCP/IP and writeQueue count is increasing
>
> Hi,
>
> it's quite simple: if the remote server does not receive anything, that
> means your server does not send anything.
>
> As it worked for a while, it's very likely something happened that
> closed the connection.
>
> * Have you received a sessionClosed() on your server?
> * Have you checked on the network side if a FW is closing the connection
> for any reason?
>
>
> In any case, MINA is just behaving as expected, it's up to you to check
> if the connection is not up and running wioth the remote serevr. that
> means if you write a message and aren't receiving a messageSent for this
> message after a while, thn you have to act accordingly.
>
> On 24/10/2024 08:23, Nitin Phuria wrote:
>> Dear All,
>>
>>
>>
>> We have developed one server using Apache MINA V2.1.6 where multiple
>> vendors connect and send the messages which needs to be processed and then
>> response have to be sent back to vendor. Currently we have put a strategy
>> that vendor has to send one message per connection and after getting
>> response or timeout vendor has to close the connection.
>>
>> We also have persistance connection open from our MINA based server
>> with third party server whcih is tcp/ip channel and for each vendor request
>> we get we have to send the received message to this third party server. Past
>> 3-4 days we have observed that application works fine for some time and then
>> suddenly all the messages written to session.write method does not go to
>> TCP/Ip and no Message sent event is generated for them. When I checked the
>> session's getWriteRequestQueue().size() it is observed that it is
>> continuously increasing only.
>>
>>
>>
>> This operation is asynchronous; IoHandler.messageSent(IoSession, Object)
>> will be invoked when the message is actually sent to remote peer. In our
>> observation we found that the messageSent was not called once we observe the
>> WriteRequestQueue(). Size started building up.
>>
>>
>>
>> When we checked with third party server they told they are not receiving any
>> messages on the port where we have opened persistence connection and they
>> are listening on it.
>>
>>
>>
>> Any possible checks that we need to do at OS level or Network level which
>> can give us lead for the problem will help. If we restart our Server then
>> again for sometime it will work and then same problem of WriteQueue size
>> build up will start.
>>
>> We have our own ProtocolCodecFactory implemented is used for
>> endocing/decoding messages from our server to third party server.
>>
>> We have no executorFilter in the chain.
>>
>>
>>
>> Below is my Protocol Encoder class
>>
>>
>>
>> public class DefaultMyMsgEncoder extends ProtocolEncoderAdapter
>> {
>> public DefaultMyMsgEncoder()
>> {
>> }
>>
>>
>>
>> public void encode(IoSession session, Object msg, ProtocolEncoderOutput
>> out) throws Exception
>> {
>>
>> MyMsg myMsg = (MyMsg) msg;
>> IoBuffer buffer =
>> IoBuffer.allocate(myMsg.getLengthBytes().length+myMsg.getMsgBytes().length
>> );
>> buffer.put(myMsg.getLengthBytes());
>> buffer.put(myMsg.getMsgBytes());
>> buffer.flip();
>> out.write(buffer);
>>
>> }
>> }
>>
>>
>>
>> Thanks in advance.
>>
>>
>>
>> Thanks And Regards,
>> Nitin Phuria
>>
>>
>
--
*Emmanuel Lécharny* P. +33 (0)6 08 33 32 61
elecharny@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@mina.apache.org
For additional commands, e-mail: users-help@mina.apache.org
RE: MINA: Messages writen to session are not getting written to TCP/IP and writeQueue count is increasing
Posted by Nitin Phuria <ni...@integramicro.com.INVALID>.
Hi,
Thanks for your quick response with few points to check.
We are not getting any sessionClosed or exceptionCaught event on this session.
We have also checked at OS level with netstat and could see that session was available with ESTABLISHED state
Also before sending any message we have below check and if this is true then only we write the message to session
if (session() != null && session().isConnected())
Pls let me know whether this above check is sufficient to assume that session is not bad and it is good to write to this session.
Also we want to understand if we are writing say 10 messages one after another to session then they will be queued up to be written to session as single thread will be doing this job. For some reason if this writing to session is failed then will it skip the current message and take up next message to write? As I understand the Codec Encoder will be called for this operation. Any error in ProtocolEncoder will have any impact if one of the message it fails to write to session.
Thanks And Regards,
Nitin Phuria
-----Original Message-----
From: Emmanuel Lécharny [mailto:elecharny@gmail.com]
Sent: 24 October 2024 23:34
To: Nitin Phuria; users@mina.apache.org
Subject: Re: MINA: Messages writen to session are not getting written to TCP/IP and writeQueue count is increasing
Hi,
it's quite simple: if the remote server does not receive anything, that
means your server does not send anything.
As it worked for a while, it's very likely something happened that
closed the connection.
* Have you received a sessionClosed() on your server?
* Have you checked on the network side if a FW is closing the connection
for any reason?
In any case, MINA is just behaving as expected, it's up to you to check
if the connection is not up and running wioth the remote serevr. that
means if you write a message and aren't receiving a messageSent for this
message after a while, thn you have to act accordingly.
On 24/10/2024 08:23, Nitin Phuria wrote:
> Dear All,
>
>
>
> We have developed one server using Apache MINA V2.1.6 where multiple
> vendors connect and send the messages which needs to be processed and then
> response have to be sent back to vendor. Currently we have put a strategy
> that vendor has to send one message per connection and after getting
> response or timeout vendor has to close the connection.
>
> We also have persistance connection open from our MINA based server
> with third party server whcih is tcp/ip channel and for each vendor request
> we get we have to send the received message to this third party server. Past
> 3-4 days we have observed that application works fine for some time and then
> suddenly all the messages written to session.write method does not go to
> TCP/Ip and no Message sent event is generated for them. When I checked the
> session's getWriteRequestQueue().size() it is observed that it is
> continuously increasing only.
>
>
>
> This operation is asynchronous; IoHandler.messageSent(IoSession, Object)
> will be invoked when the message is actually sent to remote peer. In our
> observation we found that the messageSent was not called once we observe the
> WriteRequestQueue(). Size started building up.
>
>
>
> When we checked with third party server they told they are not receiving any
> messages on the port where we have opened persistence connection and they
> are listening on it.
>
>
>
> Any possible checks that we need to do at OS level or Network level which
> can give us lead for the problem will help. If we restart our Server then
> again for sometime it will work and then same problem of WriteQueue size
> build up will start.
>
> We have our own ProtocolCodecFactory implemented is used for
> endocing/decoding messages from our server to third party server.
>
> We have no executorFilter in the chain.
>
>
>
> Below is my Protocol Encoder class
>
>
>
> public class DefaultMyMsgEncoder extends ProtocolEncoderAdapter
> {
> public DefaultMyMsgEncoder()
> {
> }
>
>
>
> public void encode(IoSession session, Object msg, ProtocolEncoderOutput
> out) throws Exception
> {
>
> MyMsg myMsg = (MyMsg) msg;
> IoBuffer buffer =
> IoBuffer.allocate(myMsg.getLengthBytes().length+myMsg.getMsgBytes().length
> );
> buffer.put(myMsg.getLengthBytes());
> buffer.put(myMsg.getMsgBytes());
> buffer.flip();
> out.write(buffer);
>
> }
> }
>
>
>
> Thanks in advance.
>
>
>
> Thanks And Regards,
> Nitin Phuria
>
>
--
*Emmanuel Lécharny* P. +33 (0)6 08 33 32 61
elecharny@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@mina.apache.org
For additional commands, e-mail: users-help@mina.apache.org
--
*
*
*Confidentiality Disclaimer**: “The information contained in this
electronic message
(email) and any attachments to this email are intended
for the exclusive use of
the addressee(s) and access to this email by
anyone else is unauthorized. The
email may contain proprietary,
confidential or privileged information or
information relating to Integra
Group. If you are not the intended recipient,
please notify the sender by
telephone, fax, or return email and delete this
communication and any
attachments thereto, immediately from your computer. Any
dissemination,
distribution, or copying of this communication and the
attachments thereto
(in whole or part), in any manner, is strictly prohibited
and actionable at
law. The recipient acknowledges that emails are susceptible
to alteration
and their integrity cannot be guaranteed and that Company does
not
guarantee that any e-mail is virus-free and accept no liability for any
damage caused by any virus transmitted by this email.”*
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@mina.apache.org
For additional commands, e-mail: users-help@mina.apache.org
Re: MINA: Messages writen to session are not getting written to TCP/IP and writeQueue count is increasing
Posted by Emmanuel Lécharny <el...@gmail.com>.
Hi,
it's quite simple: if the remote server does not receive anything, that
means your server does not send anything.
As it worked for a while, it's very likely something happened that
closed the connection.
* Have you received a sessionClosed() on your server?
* Have you checked on the network side if a FW is closing the connection
for any reason?
In any case, MINA is just behaving as expected, it's up to you to check
if the connection is not up and running wioth the remote serevr. that
means if you write a message and aren't receiving a messageSent for this
message after a while, thn you have to act accordingly.
On 24/10/2024 08:23, Nitin Phuria wrote:
> Dear All,
>
>
>
> We have developed one server using Apache MINA V2.1.6 where multiple
> vendors connect and send the messages which needs to be processed and then
> response have to be sent back to vendor. Currently we have put a strategy
> that vendor has to send one message per connection and after getting
> response or timeout vendor has to close the connection.
>
> We also have persistance connection open from our MINA based server
> with third party server whcih is tcp/ip channel and for each vendor request
> we get we have to send the received message to this third party server. Past
> 3-4 days we have observed that application works fine for some time and then
> suddenly all the messages written to session.write method does not go to
> TCP/Ip and no Message sent event is generated for them. When I checked the
> session's getWriteRequestQueue().size() it is observed that it is
> continuously increasing only.
>
>
>
> This operation is asynchronous; IoHandler.messageSent(IoSession, Object)
> will be invoked when the message is actually sent to remote peer. In our
> observation we found that the messageSent was not called once we observe the
> WriteRequestQueue(). Size started building up.
>
>
>
> When we checked with third party server they told they are not receiving any
> messages on the port where we have opened persistence connection and they
> are listening on it.
>
>
>
> Any possible checks that we need to do at OS level or Network level which
> can give us lead for the problem will help. If we restart our Server then
> again for sometime it will work and then same problem of WriteQueue size
> build up will start.
>
> We have our own ProtocolCodecFactory implemented is used for
> endocing/decoding messages from our server to third party server.
>
> We have no executorFilter in the chain.
>
>
>
> Below is my Protocol Encoder class
>
>
>
> public class DefaultMyMsgEncoder extends ProtocolEncoderAdapter
> {
> public DefaultMyMsgEncoder()
> {
> }
>
>
>
> public void encode(IoSession session, Object msg, ProtocolEncoderOutput
> out) throws Exception
> {
>
> MyMsg myMsg = (MyMsg) msg;
> IoBuffer buffer =
> IoBuffer.allocate(myMsg.getLengthBytes().length+myMsg.getMsgBytes().length
> );
> buffer.put(myMsg.getLengthBytes());
> buffer.put(myMsg.getMsgBytes());
> buffer.flip();
> out.write(buffer);
>
> }
> }
>
>
>
> Thanks in advance.
>
>
>
> Thanks And Regards,
> Nitin Phuria
>
>
--
*Emmanuel Lécharny* P. +33 (0)6 08 33 32 61
elecharny@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@mina.apache.org
For additional commands, e-mail: users-help@mina.apache.org