JPro-one / JPro-Tickets

The right place to report about bugs or suggest improvements for JPro.
https://www.jpro.one
9 stars 4 forks source link

Reloading instance on "No async message support and buffer too small" #174

Open bekasov opened 3 months ago

bekasov commented 3 months ago

Hello, we are implementing some data exchange using async js and java calls (get/set clipboard content), it works when app run from "gradle jproRun" or by unpacking a zip from the "gradle jproRelease", but when we run it with the Loadbalancer and trying to paste some more html than usual (but not so big, its about 100 rows of html table with 4 columns of text), then the app's page starts reloading and Browser's console shows the following error:

jpro - con: 1 WebSocket connection closed - code: 1009 reason: No async message support and buffer too small. Buffer size: [8,192], Message size: [2,018]

Is there some settings to grow the buffer or something else to make the Loadbalancer work?

besidev commented 3 months ago

Hello @bekasov,

Thank you for reaching out with the details of the issue you're experiencing. It seems like the root cause of the problem is related to the maximum web socket message size limitation when running your application with the Loadbalancer. The default value for the maximum message size is currently set to 1000000 bytes.

To address this issue, you can configure the one.jpro.loadbalancer.maxMessageSize property to a higher value than actual 1000000. Here’s how you can do it:

  1. Create a file named application.properties in the root directory of your application.
  2. Open the application.properties file and add the following line to specify a new maximum message size: one.jpro.loadbalancer.maxMessageSize=your_desired_size_in_bytes Replace your_desired_size_in_bytes with the maximum message size you wish to set, ensuring it's higher than the default 1000000 bytes.
  3. When starting your application with the Loadbalancer, ensure that this custom application.properties file is recognized. Typically, this involves placing the application.properties file in a directory that is loaded by the application at runtime, or use the following command line:
    java -Dspring.config.location=file:/path/to/your/custom/application.properties -jar jpro-loadbalancer.jar

This solution will help you work around the message size limitation. Meanwhile, we're actively working on a more general approach to address this issue within the JPro implementation. The goal is to make it automatically adjust to every use case, eliminating the need for manual configuration of the message size in the future.

bekasov commented 3 months ago

@besidev thank you for detailed answer, but I set the

one.jpro.loadbalancer.maxMessageSize = 100000000

and run the loadbalancer with full path of the application.settings, but it has no effect, the page keep reloading when I paste my html table. I have measured the size of inserting html - it is less than 24Kb, but if I would add one more zero to my current one.jpro.loadbalancer.maxMessageSize (now it is 100'000'000, and I trying to set 1'000'000'000), the page will start reloading constantly, without any input. It seems like the maxMessageSize is reached to the loadbalancer, but for my case it is not working. Any ideas? Maybe you mean other version of the loadbalancer, now I am using from here, version 0.10.0.

besidev commented 3 months ago

We have updated the Loadbalancer documentation. The latest release version is 0.11.0. Take a look there for more detailed information.

PS: Please make sure that the custom configuration file is called application.properties and not application.settings. I have also updated in the previous post the correct way to pass -D arguments before -jar following the standard Java command line model for every terminal:

java [-options] -jar jarfile [args...]
FlorianKirmaier commented 2 months ago

@bekasov For your information - we are working on a general solution for this Problem. Then it will always work without a configuration value (which doesn't seem to work consistently) It will be available in the next update.

bekasov commented 1 month ago

@FlorianKirmaier @besidev Hello, just for information, loadbalancer v.0.12 is still reload the page on not so big messages, complaining to buffer size and message size, and the one.jpro.loadbalancer.maxMessageSize paraneter do not give any effect, we have to run our web solution without the loadbalancer to test it. (plugin updated to 2024.2.1)

FlorianKirmaier commented 1 month ago

Thank you for the quick feedback. That's surprising, but we'll take a look. The parameter one.jpro.loadbalancer.maxMessageSize should no longer be necessary because JPro no longer internally creates big messages—if they are big, they are now split into multiples. Could you let me know if you are sure you are using both correct versions?

bekasov commented 1 month ago

Yes, I have just rechecked again, loadbalancer - 0.12, jpro - 2024.2.1, error message - jpro - con: 1 WebSocket connection closed - code: 1009 reason: No async message support and buffer too small. Buffer size: [8,192], Message size: [1,597], message size depends on size of data on my clipboard

FlorianKirmaier commented 1 month ago

Hi I've been able to reproduce this problem now with the latest version. We'll provide a fix and contact you when it's available.