Select to view content in your preferred language

Configure input/Geoevents service in GeoEvents manager

2878
2
08-26-2013 12:36 PM
KrishnaPragada1
New Contributor
Hi,

This may be simple question but I spend last 2 days to fix it without success.

1) I have created input with 'Receive Text on Tcp Socket' in ArcGIS GeoEvents Manaher which is working fine with simulator but
when I send text from my c# application, it is sending successfully but GeoEvents monitor doesn't show it and I am not seeing it in output either.

The following is the code I am using to send meassage from my app

Socket soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
System.Net.IPAddress ipAdd = System.Net.IPAddress.Parse("localhost");
System.Net.IPEndPoint remoteEP = new IPEndPoint(ipAdd, 5565);
soc.Connect(remoteEP);
byte[] byData = System.Text.Encoding.ASCII.GetBytes("Vehicle,123,Truck,15,2012-07-24T08:00:00,'-117.198361,34.055581'");
int status = soc.Send(byData);

Can anyone please help me what wrong I am doing?

Thanks,
Krishna
0 Kudos
2 Replies
HanochKalmanovich
Esri Contributor
There are a few problems with the code snippet you sent, but the main one from the GeoEvent input point of view is that the message sent is missing a Message Separator indicator. The default settings for the 'Receive text from a TCP Socket' input connector is a '\n' character:
  1. Missing Message Separator.
  2. Need to use System.Net.Dns.GetHostEntry() instead of System.Net.IPAddress.Parse() to convert a DNS entry into an IP Address.
  3. Need to use escaped quote characters to mark two fields as one with the CSV format.  This will allow you to pass a "x,y" or a "x,y,z" geometry value correctly as one CSV field.
  4. It is recommended to use UTF8 encoding.

Following is the corrected code snippet:
  // ...
  using System.Net.Sockets;
  using System.Net;
  // ...
  Socket soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  IPHostEntry hostEntry = Dns.GetHostEntry("localhost");
  IPAddress ipAdd = hostEntry.AddressList[0];
  soc.Connect(ipAdd, 5565);
  byte[] byData = System.Text.Encoding.UTF8.GetBytes("Vehicle,123,Truck,15,2012-07-24T08:00:00,\"-117.198361,34.055581\"\n");
  int bytesSent = soc.Send(byData);

-Hanoch
KrishnaPragada1
New Contributor
Thank you honoch. It is working.

Actually I am using ip address and tried with message seperator and escaped quote chanracters for x,y fields. But, I used ASCII instead of UTF8.


There are a few problems with the code snippet you sent, but the main one from the GeoEvent input point of view is that the message sent is missing a Message Separator indicator. The default settings for the 'Receive text from a TCP Socket' input connector is a '\n' character:
  1. Missing Message Separator.
  2. Need to use System.Net.Dns.GetHostEntry() instead of System.Net.IPAddress.Parse() to convert a DNS entry into an IP Address.
  3. Need to use escaped quote characters to mark two fields as one with the CSV format.  This will allow you to pass a "x,y" or a "x,y,z" geometry value correctly as one CSV field.
  4. It is recommended to use UTF8 encoding.

Following is the corrected code snippet:
  // ...
  using System.Net.Sockets;
  using System.Net;
  // ...
  Socket soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  IPHostEntry hostEntry = Dns.GetHostEntry("localhost");
  IPAddress ipAdd = hostEntry.AddressList[0];
  soc.Connect(ipAdd, 5565);
  byte[] byData = System.Text.Encoding.UTF8.GetBytes("Vehicle,123,Truck,15,2012-07-24T08:00:00,\"-117.198361,34.055581\"\n");
  int bytesSent = soc.Send(byData);

-Hanoch
0 Kudos