B4J Question jWebSocket v2: MessageTooLargeException: Text message too large

wimpie3

Well-Known Member
Licensed User
Longtime User
I get this error because the string the server returns is > 65.536 bytes.

In previous versions of jWebSocket, "setMaxTextMessageSize" could be called with a JavaObject, that doesn't seem to work anymore in jWebSocket v2.

What's the alternative? The server isn't under my control so I can't make the returned string shorter.
 

wimpie3

Well-Known Member
Licensed User
Longtime User
FYI, this is the code I'm using:
B4X:
Sub ws_Connected
    Dim maxTextSize As Long = 100000
    Dim jo As JavaObject = ws
    jo = jo.GetFieldJO("session").RunMethod("getPolicy", Null)
    jo.RunMethod("setMaxBinaryMessageBufferSize", Array(maxTextSize))
    jo.RunMethod("setMaxBinaryMessageSize", Array(maxTextSize))
    jo.RunMethod("setMaxTextMessageBufferSize", Array(maxTextSize))
    jo.RunMethod("setMaxTextMessageSize", Array(maxTextSize))
End Sub

This gives me java.lang.RuntimeException: Method: getPolicy not found in: java.util.concurrent.CompletableFuture

I think it MIGHT have something to do with me running the program in non-UI mode?
 
Last edited:
Upvote 0

wimpie3

Well-Known Member
Licensed User
Longtime User
Erel, in your example wsc needs to be replaced by client on line 3, and that makes it work! Thanks!
 
Upvote 0
Top