Dynamic TCP Port

Topics: Developer Forum, Project Management Forum
Mar 6, 2009 at 9: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
PortDebugDynamic(Microsoft.XLANGs.BaseTypes.Address)="tcp://10.222.0.166:1970";
PortDebugDynamic(Microsoft.XLANGs.BaseTypes.TransportType)="TCP";

and in my Message Contructor
msgResponse = MessageSQLResponse;
msgResponse(TCP.FrameStartDelimiter)="#S#";
msgResponse(TCP.FrameEndDelimiter)="#E#";
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 10.222.0.166:1970 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.

Serdar KALAYCI