You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ruruskyi <ro...@gmail.com> on 2013/09/24 14:14:13 UTC

why camel/mina cannot convert simple direct sequence of bytes to byte[]?

Hi,

I expect there is simple answer to my question, but I cannot manage my UDP
server working on public server. I created simple UDP server listener with
Camel and Mina/2 (I tried both). 

Route:

	from("{{udp.endpoint}}")

		.process(new Processor() {
			@Override
			public void process(Exchange exchange) throws Exception {

				AesCrypto crypto = new AesCrypto();
				byte[] body = (byte[]) exchange.getIn().getBody();
				byte[] decrypted = crypto.decrypt(body);
				exchange.getIn().setBody(decrypted);
			}
		}) ... ;

conf.properties:
udp.endpoint=mina:udp://<ip4_address>:9120?sync=false&allowDefaultCodec=false

I tried without options and with different combinations of sync and
allowDefaultCodec, with Mina and Mina2. 

When I run this on localhost (or 127.0.0.1 or 0.0.0.0) on my laptop it works
fine. I deployed the same application on the server with global static IP
address. When I am sending raw sequence of bytes from the client I am
receiving following error (mina 1):


10:51:21.585 [Camel (camel-1) thread #2 - MinaThreadPool] WARN 
o.a.c.c.m.MinaConsumer$ReceiveHandler - [/92.23.26.80:55209] Unexpected
exception from exceptionCaught handler.
org.apache.camel.CamelException:
org.apache.mina.filter.codec.ProtocolDecoderException:
org.apache.camel.NoTypeConversionAvailableException: No type converter
available to convert from type:
org.apache.mina.common.PooledByteBufferAllocator.PooledByteBuffer to the
required type: byte[] with value DirectBuffer[pos=0 lim=32 cap=32: F3 C8 4C
4E A4 13 2A 3C ED F8 86 66 C5 69 51 12 D5 97 51 2D 33 BA 0C 09 B7 74 E9 C8
72 51 E9 1D] (Hexdump: F3 C8 4C 4E A4 13 2A 3C ED F8 86 66 C5 69 51 12 D5 97
51 2D 33 BA 0C 09 B7 74 E9 C8 72 51 E9 1D)
	at
org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.exceptionCaught(MinaConsumer.java:91)
~[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.exceptionCaught(AbstractIoFilterChain.java:564)
~[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345)
[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53)
[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionCaught(AbstractIoFilterChain.java:643)
[sc2.jar:na]
	at
org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:224)
[sc2.jar:na]
	at
org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264)
[sc2.jar:na]
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[na:1.7.0_40]
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[na:1.7.0_40]
	at java.lang.Thread.run(Thread.java:724) [na:1.7.0_40]
Caused by: org.apache.mina.filter.codec.ProtocolDecoderException:
org.apache.camel.NoTypeConversionAvailableException: No type converter
available to convert from type:
org.apache.mina.common.PooledByteBufferAllocator.PooledByteBuffer to the
required type: byte[] with value DirectBuffer[pos=0 lim=32 cap=32: F3 C8 4C
4E A4 13 2A 3C ED F8 86 66 C5 69 51 12 D5 97 51 2D 33 BA 0C 09 B7 74 E9 C8
72 51 E9 1D] (Hexdump: F3 C8 4C 4E A4 13 2A 3C ED F8 86 66 C5 69 51 12 D5 97
51 2D 33 BA 0C 09 B7 74 E9 C8 72 51 E9 1D)
	at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:165)
~[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived(AbstractIoFilterChain.java:499)
~[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
[sc2.jar:na]
	at
org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(AbstractIoFilterChain.java:293)
[sc2.jar:na]
	at
org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate.readSession(DatagramAcceptorDelegate.java:400)
~[sc2.jar:na]
	at
org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate.processReadySessions(DatagramAcceptorDelegate.java:368)
~[sc2.jar:na]
	at
org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate.access$1200(DatagramAcceptorDelegate.java:61)
~[sc2.jar:na]
	at
org.apache.mina.transport.socket.nio.support.DatagramAcceptorDelegate$Worker.run(DatagramAcceptorDelegate.java:320)
~[sc2.jar:na]
	at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
~[sc2.jar:na]
	... 3 common frames omitted
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
converter available to convert from type:
org.apache.mina.common.PooledByteBufferAllocator.PooledByteBuffer to the
required type: byte[] with value DirectBuffer[pos=0 lim=32 cap=32: F3 C8 4C
4E A4 13 2A 3C ED F8 86 66 C5 69 51 12 D5 97 51 2D 33 BA 0C 09 B7 74 E9 C8
72 51 E9 1D]
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:181)
~[sc2.jar:na]
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:149)
~[sc2.jar:na]
	at
org.apache.camel.component.mina.MinaUdpProtocolCodecFactory$2.decode(MinaUdpProtocolCodecFactory.java:63)
~[sc2.jar:na]
	at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:158)
~[sc2.jar:na]
	... 14 common frames omitted


I am receiving exception from mina2 as well. Different stacktrace but
problem seems to be the same.

My UDP client:

		String data = "01463b6e661087"
				+ "01"
				+ "523ed765"
				+ "425C0B44"
				+ "BFB851EC"
				+ "4173b780"
				+ "438b1ea6"
				+ "f7bd"
				+ "0000"; // padding
		byte[] binaryData = DatatypeConverter.parseHexBinary(data);
		XXXCrypto crypto = new XXXCrypto();
		byte[] encrypted = crypto.encrypt(binaryData);

		DatagramPacket packet = new DatagramPacket(encrypted, encrypted.length,
				InetAddress.getByName("<ip4_address>"), 9120);

		DatagramSocket clientSocket = new DatagramSocket();
		clientSocket.send(packet);
		clientSocket.close();

So the questions is: why camel/mina cannot convert simple direct sequence of
byte to byte[]? Could you give me a link on example of camel/mina udp server
which receives bytes and not using ?textline=true? Why all this working on
localhost?

FYI. This UDP server is meant to be connector for bigger system, and there
are thousands of telematic devices which will be sending encoded sequences
of bytes to the server over GPRS or satellite network. 



--
View this message in context: http://camel.465427.n5.nabble.com/why-camel-mina-cannot-convert-simple-direct-sequence-of-bytes-to-byte-tp5740120.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: why camel/mina cannot convert simple direct sequence of bytes to byte[]?

Posted by ruruskyi <ro...@gmail.com>.
My version of camel is 2.11.1.



--
View this message in context: http://camel.465427.n5.nabble.com/why-camel-mina-cannot-convert-simple-direct-sequence-of-bytes-to-byte-tp5740120p5740121.html
Sent from the Camel - Users mailing list archive at Nabble.com.