B4J Question webapp : jetty how to use setMaxTextMessageSize

billzhan

Active Member
Licensed User
Longtime User
Yes, about 115kb(and maybe more). It's the data of a spreadsheet which can be edited in web page.

Another solution : the data can be sent by ajax to server and be saved, the ws event will be called after ajax success event.

I prefer to make it in the ws thread.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I actually think that it is better to use a servlet to upload the data.

However try this code:
B4X:
Sub SetMaxTextMessage(size As Int)
   Dim jo As JavaObject = ws
   jo = jo.GetFieldJO("session").RunMethod("getPolicy", Null)
   jo.RunMethod("setMaxTextMessageSize", Array(size))
End Sub

Call SetMaxTextMessage(1024 * 1024) in WebSocket_Connected sub. The code will update the internal limit (note that I haven't tested whether it actually increased the limit or not).
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I actually think that it is better to use a servlet to upload the data.

However try this code:
B4X:
Sub SetMaxTextMessage(size As Int)
   Dim jo As JavaObject = ws
   jo = jo.GetFieldJO("session").RunMethod("getPolicy", Null)
   jo.RunMethod("setMaxTextMessageSize", Array(size))
End Sub

Call SetMaxTextMessage(1024 * 1024) in WebSocket_Connected sub. The code will update the internal limit (note that I haven't tested whether it actually increased the limit or not).

This code works; the change is accepted but anyway the server will accept max 128KB or it raises an exception and the websocket will be disconnected.
 
Upvote 0
Top