Use API with JAVA

Integration questions/issues
m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Fri Jan 17, 2020 3:50 pm

You asked me, above, to set all the values to true and now to false... What is the real impact of these variables?

I set it to false in the file "local.son" and emptied the parameters "files.docservice.secret=" and "files.docservice.header=" in the file "settings.properties".

I always get the same mistake.
Also, check logs file of converter service. Go to host and run the command nano /app/onlyoffice/DocumentServer/logs/documentserver/converter/out.log
Image

EDIT :

I finally found the solution !

I use docker, so the OnlyOffice container has its own network and can't access the root address "127.0.0.1". By using the "ifconfig" command, we get the address of the common network "Ubuntu and container docker" of each element.

Image

Instead of using the address "127.0.0.1", I use the address "178.18.0.1" and I opened the access on this network with the following command :

Code: Select all

ufw allow in on docker0
I have one last question, how can I change the port of "documentserver" and not use port 80?

Alexandre
Posts: 59
Joined: Thu Dec 12, 2019 11:08 am

Re: Use API with JAVA

Post by Alexandre » Mon Jan 20, 2020 8:18 am

Hello.
We are glad that the issue was solved.
What is the real impact of these variables?
Values “true” for lines "inbox", "outbox" and "browser" activate a JWT token for security requests. So, if you set “true”, you need to set the value of the variables in the settings.properties file ( “files.docservice.secret=” and “files.docservice.header=”). Otherwise, requests will not pass.
how can I change the port of "documentserver" and not use port 80?
Please note, port 80 is a default port of Community server. Why do you want to change it? In this case, you should edit install.sh and use this script to install updates.

m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Mon Jan 20, 2020 8:35 am

Hello,

Thank you for your help and the time you gave me. ;)
Please note, port 80 is a default port of Community server. Why do you want to change it? In this case, you should edit install.sh and use this script to install updates.
My main application is already running on port 80. The document service will be integrated into it. So I'm going to modify the installation file "install.sh".

Have a good day

Alexandre
Posts: 59
Joined: Thu Dec 12, 2019 11:08 am

Re: Use API with JAVA

Post by Alexandre » Mon Jan 20, 2020 10:01 am

You can edit ports in these lines in install.sh:
check_ports () {
ARRAY_PORTS=();
if [ "$INSTALL_COMMUNITY_SERVER" == "true" ]; then
ARRAY_PORTS=(${ARRAY_PORTS[@]} "80" "443" "5222");
elif [ "$INSTALL_DOCUMENT_SERVER" == "true" ]; then
if [ "${USE_AS_EXTERNAL_SERVER}" == "true" ]; then
ARRAY_PORTS=(${ARRAY_PORTS[@]} "80" "443");
fi
fi

......

install_community_server () {
COMMUNITY_PORT=80

......

if [ "$RUN_COMMUNITY_SERVER" == "true" ]; then
args=();
args+=(--name "$COMMUNITY_CONTAINER_NAME");
args+=(-p "$COMMUNITY_PORT:80");
args+=(-p 443:443);
args+=(-p 5222:5222);
Keep in mind in future that to update ONLYOFFICE you will need to use edited install.sh

m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Mon Jan 20, 2020 10:49 am

Thank you Alexandre, I take note of his information and come back to you if I have a problem.

m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Fri Jan 24, 2020 9:35 am

Hello Alexandre,

I tried to install Only Office by modifying the "install.sh" file. I wanted to use port 82 instead of the default port 80.
You can edit ports in these lines in install.sh:
...
Keep in mind in future that to update ONLYOFFICE you will need to use edited install.sh
This solution doesn't work, the script goes well to the end but when I go to the page "127.0.0.1:82", it's untraceable.

Image

I used the following command to display the Docker containers and their ports of use:

Code: Select all

sudo docker container ls
And here's the result:

Image

You can see that port 80 is still in use.

I tried once by changing the ports you gave me in the file. It didn't work. Then I tried a second time by changing all the "80" by "82" in the file, the problem is the same.

Alexandre
Posts: 59
Joined: Thu Dec 12, 2019 11:08 am

Re: Use API with JAVA

Post by Alexandre » Fri Jan 24, 2020 12:54 pm

Hello m.allain
Please provide some additional information:
1. Try to access the portal via domain name or ip address.
2. Check if the port 82 is open.

m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Wed Feb 05, 2020 12:10 pm

Hello Alexandre,

After a long research, I found the solution to deploy OnlyOffice (Community and Document Server) on another port than 80. In my case, port 82. ;)

I redid my installation without modifying the files "opensource-install.sh" and "install.sh".
First of all, please check the IDs of the "DocumentServer" and "CommunityServer" containers.

Code: Select all

sudo docker container ls
In my case:
  • 065d512f99fc : « CommunityServer »,
  • 03a8f605a147 : « DocumentServer ».
Step 1: stop docker

Code: Select all

sudo service docker stop
Step 2: use nautilus to access the configuration files of each container:

Code: Select all

sudo nautilus
Step 3: Changing the ports used

Step 3-a: For the "CommunityServer" project
  • Go to the "/var/lib/docker/containers" folder,
  • Go to the folder whose name starts with the container ID ("065d512f99fc..."),
  • Modify the file "hostconfig.json",
Image
  • Replace the green "80" with "82".
Step 3-a: For the "DocumentServer" project
  • Go to the "/var/lib/docker/containers" folder,
  • Go to the folder whose name starts with the container ID ("03a8f605a147..."),
  • Modify the file "config.v2.json",
Image
  • Replace the green "80" with "82".
Step 4: leave nautilus and start docker

Code: Select all

sudo service docker start
Final Result

Image

Image

Alexandre
Posts: 59
Joined: Thu Dec 12, 2019 11:08 am

Re: Use API with JAVA

Post by Alexandre » Wed Feb 05, 2020 2:39 pm

Glad to see you m.allain!
We are glad that the issue was solved. Please note, we didn’t test your method and can’t provide a guarantee of further stable work.
One more point, we still didn’t find the reason of incorrect installation of the changed script install.sh. if something happens wrong, we will return to this topic.

m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Tue Feb 11, 2020 8:32 am

Hello Alexandre,

I can now use, in JAVA, the API provided by the "DocumentServer" and it works correctly (authentication, folder creation, file upload, ...) :)
During authentication, I receive a token with an expiration date of one year, which I then use for all my requests.
After a few minutes of use or I make various requests to the DocumentServer, JAVA returns me the error:

Code: Select all

Connection reset
I tried, by performing an authentication before each request, but the problem remains the same... :shock:

Do you have an idea of the origin of this problem or have you encountered this kind of problem before?

EDIT :
I've come up with this explanation, I'll look at my firewall:

Image

Post Reply