Best way to start LT as a https server

Hello folks,

I’m trying to set up my own LT instance. What is the best way to start LT as https server?

Now I use “/opt/java/bin/java -jar ./languagetool-server.jar --config ./server.cfg --port 8081”. Most time it works fine, but sometimes nginix (I use it in front of LT) can’t establish a connection with LT in reasonable time.

Let me show you an example

[16:36:56] “POST /v2/check HTTP/1.1” 200 3147 “-” “time:0.072/0.175/0.177”
[16:37:03] “POST /v2/check HTTP/1.1” 200 3147 “-” “time:0.070/0.148/0.149”
[16:52:49] “POST /v2/check HTTP/1.1” 200 3147 “-” “time:0.204/1.373/1.376”
[17:05:43] “POST /v2/check HTTP/1.1” 504 183 “-” “time:10.009/10.009/10.009”
[17:06:03] “POST /v2/check HTTP/1.1” 200 3147 “-” “time:0.073/0.238/0.240”

At 16:52:49 LT responded in 0.2sec, but at 17:05:43 it took more than 10sec to establish a connection to LT. Shortly after that (at 17:06:03) everything was fine again.

What is the root cause of such behaviour? Maybe I somehow tune java vitrual machine environment for getting more predictable response time?

1 Like

You should use -Xmx to increase memory, e.g. -Xmx1000M. You can also use java -cp languagetool-server.jar org.languagetool.server.HTTPServer to use HTTP, as nginx will care about running HTTPS to the internet, so there’s usually no need to use HTTPS internally.

Thank you for reply, I’ve made adjustments, but seems it didn’t help

/opt/java/bin/java -Xmx1024M -cp ./languagetool-server.jar org.languag…

19:34:26 “POST /v2/check HTTP/1.1” 200 2597 time:0.000/0.057/0.057"
19:35:34 “POST /v2/check HTTP/1.1” 504 183 time:10.010/10.010/10.010"
19:36:05 “POST /v2/check HTTP/1.1” 504 183 time:10.010/10.010/10.010"
19:36:15 “POST /v2/check HTTP/1.1” 200 2597 time:0.000/0.060/0.060"

For unknown reasons, sometimes it takes more than 10sec to establish conection to LT

tcpdump shows that LT does’t respond to SYN requests

19:45:58.808568 IP 127.0.0.1.6426 > 127.0.0.1.8081: Flags [S], seq 410190957, win 65483, options [mss 65495,sackOK,TS val 3527789171 ecr 4140056447,nop,wscale 7], length 0
19:45:59.808462 IP 127.0.0.1.6426 > 127.0.0.1.8081: Flags [S], seq 410190957, win 65483, options [mss 65495,sackOK,TS val 3527790171 ecr 4140056447,nop,wscale 7], length 0
19:46:01.808458 IP 127.0.0.1.6426 > 127.0.0.1.8081: Flags [S], seq 410190957, win 65483, options [mss 65495,sackOK,TS val 3527792171 ecr 4140056447,nop,wscale 7], length 0
19:46:05.808457 IP 127.0.0.1.6426 > 127.0.0.1.8081: Flags [S], seq 410190957, win 65483, options [mss 65495,sackOK,TS val 3527796171 ecr 4140056447,nop,wscale 7], length 0
19:46:05.808485 IP 127.0.0.1.8081 > 127.0.0.1.6426: Flags [S.], seq 650693972, ack 410190958, win 65483, options [mss 65495,sackOK,TS val 3527796171 ecr 3527796171,nop,wscale 7], length 0
19:46:05.808511 IP 127.0.0.1.6426 > 127.0.0.1.8081: Flags [.], ack 1, win 512, options [nop,nop,TS val 3527796171 ecr 3527796171], length 0

What version of Java are you using (java -version)? We use the same setup on languagetool.org, only that we use even more memory (2200M) and we use Apache instead of nginx.

Thank you,

java version “1.8.0_131”
Java™ SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot™ 64-Bit Server VM (build 25.131-b11, mixed mode)

I added additional memory to LT (2200) and will monitor LT behaviour.

the same thing :frowning:

for unknown reason LT freezes and doesn’t respond to SYN packets.

20:40:55.307416 IP 127.0.0.1.13624 > 127.0.0.1.8081: Flags [S], seq 3751482443, win 65483, options [mss 65495,sackOK,TS val 3531085670 ecr 4143355888,nop,wscale 7], length 0
20:40:56.307414 IP 127.0.0.1.13624 > 127.0.0.1.8081: Flags [S], seq 3751482443, win 65483, options [mss 65495,sackOK,TS val 3531086670 ecr 4143355888,nop,wscale 7], length 0
20:40:58.307511 IP 127.0.0.1.13624 > 127.0.0.1.8081: Flags [S], seq 3751482443, win 65483, options [mss 65495,sackOK,TS val 3531088670 ecr 4143355888,nop,wscale 7], length 0
20:41:02.307409 IP 127.0.0.1.13624 > 127.0.0.1.8081: Flags [S], seq 3751482443, win 65483, options [mss 65495,sackOK,TS val 3531092670 ecr 4143355888,nop,wscale 7], length 0
20:41:10.307406 IP 127.0.0.1.13624 > 127.0.0.1.8081: Flags [S], seq 3751482443, win 65483, options [mss 65495,sackOK,TS val 3531100670 ecr 4143355888,nop,wscale 7], length 0
20:41:10.307421 IP 127.0.0.1.8081 > 127.0.0.1.13624: Flags [S.], seq 662010632, ack 3751482444, win 65483, options [mss 65495,sackOK,TS val 3531100670 ecr 3531100670,nop,wscale 7], length 0
20:41:10.307430 IP 127.0.0.1.13624 > 127.0.0.1.8081: Flags [.], ack 1, win 512, options [nop,nop,TS val 3531100670 ecr 3531100670], length 0

Is there a lot of traffic, i.e. many connections at the same time? Or are there huge requests? You could try with Apache to have a comparison. And Apache works fine on languagetool.org (which runs Ubuntu 16.04).

Hi,

I am also running a (small) server with nginx, but I didn’t run into your issue. (Maybe because I am only using it for my personal devices)

In case it helps you:
/etc/systemd/system/languagetool.service:

[Unit]
Description=languagetool server
Requires=network.target
After=network.target

[Service]
ExecStart=/usr/bin/java -cp /srv/server/languagetool/LanguageTool/languagetool-server.jar org.languagetool.server.HTTPServer --port 8081 --config /srv/server/languagetool/server.properties
Type=simple
User=languagetool
Group=languagetool
[Install]
WantedBy=multi-user.target

(/srv/server/languagetool/server.properties is empty at the moment)
/etc/nginx/sites-available/languagetool

server {
                listen [::]:443 ssl http2;
                listen 443 ssl http2;
                server_name languagetool.example.com;

                location / {
                                proxy_pass         http://127.0.0.1:8081/;
#                               proxy_redirect     off;
                                proxy_set_header   Host                 $host;
                                proxy_set_header   X-Real-IP            $remote_addr;
                                proxy_set_header   X-Forwarded-For      $proxy_add_x_forwarded_for;
                                proxy_set_header   X-Forwarded-Proto    $scheme;
                }
}
➜  ~ /usr/bin/java -version 
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

I used to run LT inside virtrual machine (openvz), as soon as moved LT to the host systems all problems with tcp packets drop have gone.

Now it works fine, thank you.