4

For testing purposes I am sending tcp messages to a local server as follows:

echo -e "some message" | netcat localhost 1234

With netcat installed using brew install netcat.

This works fine except for that this blocks for quite a long time (about a minute). I tried to use the options "-w 1" for specifying the timeout, but this does not change anything.

The process listening on the other end is a spring-xd tcp source.

Is there any other way of sending a tcp message that does not block as long?

user152468
  • 3,202
  • 6
  • 27
  • 57

1 Answers1

8

I've not seen such a delay on linux; haven't tried on OS X (it comes with nc instead).

What is your stream definition? The default tcp source expects data to be terminated with CRLF - e.g telnet localhost 1234. You need a RAW decoder for netcat.

EDIT:

I just tested

xd:>stream create foo --definition "tcp --decoder=RAW | log" --deploy

with

$ echo "foo" | nc localhost 1234

and had no problems.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Thanks for the useful information. I did not know about the --decoder=RAW option. This works fine for me on linux. Yet I am still having trouble on Mac OS 10.10. I will once again check that my setup is correct. – user152468 Mar 31 '15 at 07:59
  • `decoder=RAW` means the end of the message is signaled by the client closing the socket. See the [Spring Integration documentation](http://docs.spring.io/spring-integration/reference/html/ip.html#connection-factories) for more information about message demarcation (scroll down to the paragraph starting `TCP is a streaming protocol...`). I am on 10.9.5 but I wouldn't expect any differences in this area. The [values for decoder](http://docs.spring.io/spring-xd/docs/1.1.1.RELEASE/reference/html/#tcp) correspond to the various deserializers documented there. – Gary Russell Mar 31 '15 at 08:10