Dynamic TCP Port

Topics: Developer Forum, Project Management Forum
Mar 6, 2009 at 8:51 AM
Hi there,
I have to send messages to handheld devices, so I think TCP Adapter would be a good solution to this. Devices have dynamic IPs so, have to use Dynamic TCP port to change the endpoint on runtime.
I put an Expression shape onto my orchestration and wrote down

and in my Message Contructor
msgResponse = MessageSQLResponse;
and expected it to write the SQL Query result to the TCP client.
When I first tried, no message was sent and there was an error in the Application Log, reading:
The transmission of the data to the remote endpoint failed.  The exception that was thrown is Array cannot be null.
Parameter name: dstEncoding

So I went into code, attached the debugger and saw that SendLocation object's FrameStart, FrameEnd and DataEncoding properties are null. So I wrote some lines to fill them up
ASCIIEncoding encoding = new ASCIIEncoding();
this._frameStart = encoding.GetBytes("#S#");
this._frameEnd= encoding.GetBytes("#E#");
this._dataEncoding = Encoding.UTF8;

This time the message was sent, but just start delimiter and the first character of the message (#S#<) and an exception thrown after the line
long totalBytesSent = SocketIO.SendData(this.Adapter, endpointSocket, new Stream[] { workItem.SendLocation.Message.BodyPart.Data }, workItem.SendLocation.FrameStart, workItem.SendLocation.FrameEnd, workItem.SendLocation.DataEncoding, workItem.SendLocation.SendDataBufferSize);
The excepiton says that:
An established connection was aborted by the software in your host machine

Everything works OK when I create a Static Port with the same values, so I'm confused and stuck here. Any help will be appreciated.