Problems using TextLineCodecFactory

View: New views
5 Messages — Rating Filter:   Alert me  

Problems using TextLineCodecFactory

by smokie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I am having some problems with the TextLineCodecFactory & Mina 2.0.0.
For some reason when I try to receive some data as a client I get
this:

DEBUG [com.test.XMPPHandler] - Session Created
DEBUG [com.test.XMPPHandler] - Message Sent: <stream:stream
xmlns="jabber:client" to="jabber.org"
xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en"
version="1.0">
DEBUG [org.apache.mina.filter.codec.ProtocolCodecFilter] - Processing
a MESSAGE_RECEIVED for session 1
DEBUG [com.test.XMPPHandler] - Session Idle

The ProtocolCodecFilter claims that it is processing the data, but my
handler never receives it. I managed to monitor the incoming data
using Wireshark, and it looks as expected. I only have one codec which
is added in the handler under the sessionOpened method like:

session.getFilterChain().addLast("codec", new ProtocolCodecFilter(new
TextLineCodecFactory(Charset.forName("UTF-8"))));

What would be the reason for this?
--
Best Regards,
Mark Wallsgrove

Re: Problems using TextLineCodecFactory

by elecharny-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mark Wallsgrove wrote:
> Hi all,
>  
Hi,

Is there a new line sent at the very end off your incoming message, so
that the textLineDecoder can know that the message has been fully received ?

> I am having some problems with the TextLineCodecFactory & Mina 2.0.0.
> For some reason when I try to receive some data as a client I get
> this:
>
> DEBUG [com.test.XMPPHandler] - Session Created
> DEBUG [com.test.XMPPHandler] - Message Sent: <stream:stream
> xmlns="jabber:client" to="jabber.org"
> xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en"
> version="1.0">
> DEBUG [org.apache.mina.filter.codec.ProtocolCodecFilter] - Processing
> a MESSAGE_RECEIVED for session 1
> DEBUG [com.test.XMPPHandler] - Session Idle
>
> The ProtocolCodecFilter claims that it is processing the data, but my
> handler never receives it. I managed to monitor the incoming data
> using Wireshark, and it looks as expected. I only have one codec which
> is added in the handler under the sessionOpened method like:
>
> session.getFilterChain().addLast("codec", new ProtocolCodecFilter(new
> TextLineCodecFactory(Charset.forName("UTF-8"))));
>
> What would be the reason for this?
>  


--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



Re: Problems using TextLineCodecFactory

by smokie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Emmanuel,

From looking at the hex it doesn't look like there is. Is there any
way to get around this?

Best Regards,
Mark Wallsgrove

2009/11/4 Emmanuel Lecharny <elecharny@...>:

> Mark Wallsgrove wrote:
>>
>> Hi all,
>>
>
> Hi,
>
> Is there a new line sent at the very end off your incoming message, so that
> the textLineDecoder can know that the message has been fully received ?
>>
>> I am having some problems with the TextLineCodecFactory & Mina 2.0.0.
>> For some reason when I try to receive some data as a client I get
>> this:
>>
>> DEBUG [com.test.XMPPHandler] - Session Created
>> DEBUG [com.test.XMPPHandler] - Message Sent: <stream:stream
>> xmlns="jabber:client" to="jabber.org"
>> xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en"
>> version="1.0">
>> DEBUG [org.apache.mina.filter.codec.ProtocolCodecFilter] - Processing
>> a MESSAGE_RECEIVED for session 1
>> DEBUG [com.test.XMPPHandler] - Session Idle
>>
>> The ProtocolCodecFilter claims that it is processing the data, but my
>> handler never receives it. I managed to monitor the incoming data
>> using Wireshark, and it looks as expected. I only have one codec which
>> is added in the handler under the sessionOpened method like:
>>
>> session.getFilterChain().addLast("codec", new ProtocolCodecFilter(new
>> TextLineCodecFactory(Charset.forName("UTF-8"))));
>>
>> What would be the reason for this?
>>
>
>
> --
> --
> cordialement, regards,
> Emmanuel Lécharny
> www.iktek.com
> directory.apache.org
>
>
>



--
Best Regards,
Mark Wallsgrove

Re: Problems using TextLineCodecFactory

by will.schick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The text line codec does exactly what it's title implies, sends a line. I would recommend using a different codec set. Using a size header as opposed to some delimiting character will give a more robust solution; sending a message which is delimited by some arbitrary character will not let you use that character in the message, so your XML won't be able to have any new lines in it if you use the textlinecodec.

Will

----- Original Message -----
From: "Mark Wallsgrove" <mark.wallsgrove@...>
To: users@...
Sent: Wednesday, November 4, 2009 9:43:32 AM GMT -06:00 US/Canada Central
Subject: Re: Problems using TextLineCodecFactory

Hi Emmanuel,

From looking at the hex it doesn't look like there is. Is there any
way to get around this?

Best Regards,
Mark Wallsgrove

2009/11/4 Emmanuel Lecharny <elecharny@...>:

> Mark Wallsgrove wrote:
>>
>> Hi all,
>>
>
> Hi,
>
> Is there a new line sent at the very end off your incoming message, so that
> the textLineDecoder can know that the message has been fully received ?
>>
>> I am having some problems with the TextLineCodecFactory & Mina 2.0.0.
>> For some reason when I try to receive some data as a client I get
>> this:
>>
>> DEBUG [com.test.XMPPHandler] - Session Created
>> DEBUG [com.test.XMPPHandler] - Message Sent: <stream:stream
>> xmlns="jabber:client" to="jabber.org"
>> xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en"
>> version="1.0">
>> DEBUG [org.apache.mina.filter.codec.ProtocolCodecFilter] - Processing
>> a MESSAGE_RECEIVED for session 1
>> DEBUG [com.test.XMPPHandler] - Session Idle
>>
>> The ProtocolCodecFilter claims that it is processing the data, but my
>> handler never receives it. I managed to monitor the incoming data
>> using Wireshark, and it looks as expected. I only have one codec which
>> is added in the handler under the sessionOpened method like:
>>
>> session.getFilterChain().addLast("codec", new ProtocolCodecFilter(new
>> TextLineCodecFactory(Charset.forName("UTF-8"))));
>>
>> What would be the reason for this?
>>
>
>
> --
> --
> cordialement, regards,
> Emmanuel Lécharny
> www.iktek.com
> directory.apache.org
>
>
>



--
Best Regards,
Mark Wallsgrove

Re: Problems using TextLineCodecFactory

by elecharny-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mark Wallsgrove wrote:
> Hi Emmanuel,
>
> >From looking at the hex it doesn't look like there is. Is there any
> way to get around this?
>  
If you don't have new lines in your message, then using a *textline*
codec is not going to solve your problem.

As you are trying to decode XML document, the only solutuon is to either
wrap your own codec (good luck...) or to have a look at the Vysper
subproject which is all about XMPP : http://mina.apache.org/vysper/

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org