Set POST size in Java?

Hi, do anyone know how to set/change the HTTP POST size in Java?
For example set the POST size for this Java code:
public static void main(String[] args) throws ClientProtocolException, IOException, JSONException {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(“http://127.0.0.1:1113”);
StringEntity input = new StringEntity(“hahaha”);
//post.addHeader(“content-type”, “application/json”);
post.setEntity(input);
post.setHeader(“test”, “exempel”);
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = “”;
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
I get exceptions in my command prompt that the package size is out of bounds when I´m trying to do a post to Event Store.
Error: Package size is out of bounds: 1414745936 (max: 67108864)…

The opposite error this time. You are posting to the tcp server (like the akka client) you want to post to port 2113 :slight_smile:

Okay if I am going to use port 2113, why isn´t there happening something to event store when I´m doing a POST to port 2113?
The Java code gets executed and build succesfull, but nothing happens in Event Store.
Why?

The ESJ Java Client is using port 1113 when I´m creating an event, and that works fine. Why is this working on port 1113?

Okay if I am going to use port 2113, why isn´t there happening something
to event store when I´m doing a POST to port 2113?
The Java code gets executed and build succesfull, but nothing happens in
Event Store.
Why?

How are you measuring that nothing is happening? What are you posting, what
is the return status code etc?

The ESJ Java Client is using port 1113 when I´m creating an event, and
that works fine. Why is this working on port 1113?

--

Because it talks protobufs over tcp not http. There are two separate
protocols

**How are you measuring that nothing is happening? What are you posting, what is the return status code etc?**I´m using this code for the POST:

public static void main(String[] args) throws ClientProtocolException, IOException, JSONException {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(“http://127.0.0.1:2113”);
StringEntity input = new StringEntity(“hahaha”);
//post.addHeader(“content-
type”, “application/json”);
post.setEntity(input);
post.setHeader(“test”, “exempel”);
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = “”;
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}

Do I miss anything, so it could write events and streams to Event Store?
Try it by yourself, I get no result that I can print out through the:
while ((line = rd.readLine()) != null) {
System.out.println(line);
}

try

http://127.0.0.1:2113/streams/foo also you might want to read through docs a bit as you are missing some headers etc in your post https://github.com/eventstore/eventstore/wiki

Okay, http://127.0.0.1:2113/streams/foo didn´t work.

Which parameters etc do you mean? In docs, it specifies curl requests.
Which parameters in my Java code do I miss?

It works fine to use curl for creating streams and events. But how to do this HTTP POST with my Java-code?

You are missing headers and content type etc (they are on the curl commands)

Okay thanks!

What am I doing wrong here:
public class TestPost {
// static String requestHeaders[];
// static String responseHeaders[];
public static void main(String[] args) throws ClientProtocolException, IOException, JSONException {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(“http://127.0.0.1:2113/streams/newstreamet”);
post.addHeader(“content-type”, “application/json”);
post.addHeader(“ES-EventType”, “SomeEvent”);

    JSONObject jo = new JSONObject();
    jo.put("title:", "DareDevs-DDDNorth3");
    jo.put("lastName:", "Doe");
   
    JSONArray ja = new JSONArray();
    ja.put(jo);
    ja.put(new Integer(10));
   
    StringEntity input = new StringEntity(ja.optString(0));     
    post.setEntity(input);
    HttpResponse response = client.execute(post);
    BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    String line = "";
    while ((line = rd.readLine()) != null) {
        System.out.println(line);
    }
}

}
I get this message in the command prompt:

[06240,24,12:58:59.669] ‘{“lastName:”:“Doe”,“title:”:“DareDevs-DDDNorth3”}’ is n
ot a valid serialized EventStore.Core.Messages.HttpClientMessageDto+ClientEventD
ynamic[]
Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type ‘Ev
entStore.Core.Messages.HttpClientMessageDto+ClientEventDynamic[]’ because the ty
pe requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or chang
e the deserialized type so that it is a normal .NET type (e.g. not a primitive t
ype like integer, not a collection type like an array or List) that can be de
serialized from a JSON object. JsonObjectAttribute can also be added to the type
to force it to deserialize from a JSON object.
Path ‘lastName:’, line 1, position 13.

What version are you running against? There is a recent change regarding content types that it discussed on the documentation page for writing over http.

Try sending up this with data as your data (and no header for EventType):


[
  {
    "eventId": "fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4",
    "eventType": "event-type",
    "data": { "a": "1" }
  }
]