I have a client app on Android using Java, and a server on my laptop in a Unity game. Both are on same network, and I got them to connect. When I send a small string message from client to server, though, the server blocks it with this warning:
`ReadMessageBlocking: possible allocation attack with a header of 1298494342 bytes.` How should I even *begin* approaching this roadblock?

For server, I'm using Unity's [Mirror](https://github.com/vis2k/Mirror/) library, that is built on top of the [Telepathy](https://github.com/vis2k/Telepathy/) framework.
For client, I followed the client part of [this](http://www.coderzheaven.com/2017/05/01/client-server-programming-in-android-send-message-to-the-client-and-back/) tutorial.

[This](https://github.com/vis2k/Telepathy/blob/master/Telepathy/Common.cs) (from Telepathy) contains the relevant method (`ReadMessageBlocking`) that throws this warning. I tried setting the `MaxMessageSize` to `int.MaxValue` (which comes to 2 GB) to at least accept the message so I could inspect it by printing its contents, but no avail.

I don't have a problem with `ReadMessageBlocking`, it's there for good reason. My concern is: Why in the world is my android, allegedly, sending a 1 GB header with the string? What can I do about it?

Edit: This is the relevant function that sends message from client (as given in the tutorial mentioned earlier.)

```
void sendMessage(final String message) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (null != socket) {
                            PrintWriter out = new PrintWriter(new BufferedWriter(
                                    new OutputStreamWriter(socket.getOutputStream())),
                                    true);
                            out.println(message);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }

    }

```

For (Unity) server to receive, I didn't write anything. The warning comes from Telepathy's internal message handling function, which I think is the [ReceiveLoop](https://github.com/vis2k/Telepathy/blob/master/Telepathy/Common.cs) here.