Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

maximum size for "arguments" of wampCliet.publish(token, args) ? #67

Closed
datsat opened this issue Aug 25, 2015 · 5 comments
Closed

maximum size for "arguments" of wampCliet.publish(token, args) ? #67

datsat opened this issue Aug 25, 2015 · 5 comments

Comments

@datsat
Copy link

datsat commented Aug 25, 2015

Is there a maximum size for the arguments when publishing an event?

I use this code (java): wampClient.publish(token, response.toString());

response.toString()) is a long json-string in my case. It has about 70.000 characters. I have the suspicion that the event does not get published, because when I replace response.toString with a short string, the event gets published as expected.

I dont know much about the internals of Wamp and an initial debugging session into the code did not provide me with much insight. As I said above, I think that the long string is causing some problems.

Any help/feedback is welcome. If you need more information, please let me know.

@Matthias247
Copy link
Owner

Hi. There is a maximum websocket frame size configured by Netty that equals to 64kb. Messages bigger than that size won't be delivered and maybe also the connection will get dropped. Don't know exactly.

However you can overwrite that limit through the NettyWampConnectionConfig class, which you can provide to the NettyWampClientConnectorProvider class. That should resolve the issue.

@beta2k
Copy link

beta2k commented Aug 26, 2015

Thank you very much, this helped (posting from another account right now).

As you said, we had to change static final int DEFAULT_MAX_FRAME_PAYLOAD_LENGTH = 65535; (see NettyWampConnectionConfig.java:8 ) to a higher value. we now changed it to static final int DEFAULT_MAX_FRAME_PAYLOAD_LENGTH = 2147483648; which equals 2^31.

so now, my event with about 70.000 characters in the argument arrives successfully at the subscriber. the new limit seems to be, however, 16.777.216 bytes (2^24 bytes or ~16mb). I will not exceed this limitiation for now, but I am really interested in who imposes this new limitation? Is there some other knob which I can turn around to still increase it?

EDIT: I just found out that the 16mb limitation comes from MAX_WEBSOCKET_FRAME_SIZE in WampHandlerConfiguration.java:22. So I just increased it. Is there something to be aware of when increasing the size of this?

@Matthias247
Copy link
Owner

You don't need to change the jawampa source code and the DEFAULT_MAX_FRAME_PAYLOAD_LENGTH variable, you can just do

client =
WampClientBuilder.withConnectorProvider(new NettyWampClientConnectorProvider())
                 .withConnectionConfiguration((new NettyWampConnectionConfig.Builder()).withMaxFramePayloadLength(2147483648).build())
                 ....
                 .build();

Yes, you can change MAX_WEBSOCKET_FRAME_SIZE according to your needs. Just be aware that if you increase those limits that if malicous clients/servers pretent to send you very large websocket frames your application will try to allocate that amount of memory which can cause memory leaks or even crashes.

@datsat
Copy link
Author

datsat commented Aug 27, 2015

Thank you very much for your support, everything is perfect now

@sebastianwahn
Copy link

sebastianwahn commented Sep 13, 2016

@Matthias247 can you put this somewhere on your README.md page? I had this issue also and tried to figure out whats the problem until i stumbled now on this solved ticket. Some FAQ or known issue sections with links to the solution would be great!

Unfortunately, the error handler on the makeSubscription is not triggered when the limit is exceeded. Maybe this would be also some good place to hint that something goes wrong?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants