cancel
Showing results for 
Search instead for 
Did you mean: 

Cann't read data from socket csv input adapter

Former Member
0 Kudos

Here is the ccl code:

CREATE INPUT WINDOW InputWindow1 SCHEMA (

  id INTEGER ,

  name string ,

  age INTEGER ) PRIMARY KEY ( id ) KEEP ALL ROWS ;

ATTACH INPUT ADAPTER Socket_CSV_Input1 TYPE toolkit_socket_csv_input TO InputWindow1 PROPERTIES host = '10.128.162.179' ,

  port = 4700 ,

  csvExpectStreamNameOpcode = FALSE ,

  csvDelimiter = ',' ,

  csvHasHeader = FALSE ;

And I have a simple JAVA socketserver to publish data, and here is the java code:

However, when I tried to run the java project and esp project, I got nothing in the window. The log file in esp said that:

     received record for unknown stream. Index: 16

In the java project console, it shows that the socketserver worked fine, and publish data every 1 second.

So, how can I fix this problem?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kevin,

Check your project's "frameworkadapter.log" file.  It will contain errors related to the toolkit based adapters (identifiable by the TYPE in your CCL).  When I run your reproduction I see:

05-30-2014 14:08:52.239 ERROR [Thread-18] (CSVInputFormatter.parseCSV) Error code:402002, Severity : 3 (Error)

Error message:CSV line contains 1 fields, expected 3.

Error description:CSV line contains 1 fields, expected 3.

05-30-2014 14:08:52.240 ERROR [Thread-18] (CSVInputFormatter.convert) Error code:402005, Severity : 3 (Error)

Error message:CSV Formatter failed to convert a string: ??

This tells me that there is a mismatch in what your Java program is sending and what the ESP adapter is expecting.  I think ObjectOutputStream sends some extra information.  According to the Java docs (http://docs.oracle.com/javase/7/docs/api/java/io/ObjectOutputStream.html), ObjectOutputStream outputs:
"Primitive data, excluding serializable fields and externalizable data, is written to the ObjectOutputStream in block-data records. A block data record is composed of a header and data. The block data header consists of a marker and the number of bytes to follow the header. Consecutive primitive data writes are merged into one block-data record. The blocking factor used for a block-data record will be 1024 bytes. Each block-data record will be filled up to 1024 bytes, or be written whenever there is a termination of block-data mode. Calls to the ObjectOutputStream methods writeObject, defaultWriteObject and writeFields initially terminate any existing block-data record."

I think ESP is just looking for a CSV string so if I change your code as follows it works for me:


//private ObjectOutputStream out;
private PrintStream out;

//out = new ObjectOutputStream(client.getOutputStream());
out = new PrintStream(client.getOutputStream(),true);

out.println(++i + ",kevin,20");
//out.writeObject(++i + ",kevin,20");
//out.flush();

If you are not sure what format an adapter is expecting, it helps to look at the "adapter_config.xml" file (%ESP_HOME%\adapters\framework\instances\socket_csv_input\adapter_config.xml) and then look at either:

   Transporter Modules

or
   Formatter Modules

Thanks,

  Neal

Former Member
0 Kudos

Hi Neal,

     Thanks for your answer, and I have solve this problem, but in another way.  I replace the ObjectOutputStream with DataOutputStream, and use the methed "writeBytes". In this way, I also get the right workflow. Anyway, thank you all the same.

Best Regards,

Kevin

Answers (0)