📜 ⬆️ ⬇️

First steps to an online office on Linux or how we ported to Mono (about the difficulties and how to overcome them)



Yesterday we released ONLYOFFICE under Linux and we hasten to share not only the news, but also useful information for those who, like us, 5 years ago found themselves in their own trap called “ASP.Net”

Attempts to port the application to Unix using the Mono project were started 4 years ago, however, for a long time we did not succeed, because at that time Mono was far behind in functionality when porting from .Net under Windows. In particular, wcf support was severely curtailed in Mono, and asp.net mvc was not working well. However, all these years, fortunately for developers, the Mono project has been actively developing - support for .Net 4.0 and .Net 4.5 has been added, so in spring 2013 we decided to resume work.
')
Here we will talk about what problems we encountered in the process of porting the cloud office to Mono, how they were decided that we have in the end, and as one initiative user, within a couple of hours after the release, I wrapped everything in Dockerfile.

The main difficulties when porting to Mono



1. Work with the file system


What is happening: the site does not open, images are not displayed or displayed incorrectly. Now the problem is described in detail on the official website of the Mono Project.

What is the matter: in Windows, forward and backward slash are the same thing, and in Unix they are two completely different ways. On Windows, paths are case insensitive, and on Unix, they are different names.
How to solve a problem:

2. Non-closing transactions


What happens: non-closing transactions in the MySQL database.
What is the matter: unfortunately, they have not figured out until the end (there are suggestions?)
As decided: added a parameter in the connection string AutoEnlist = false

3. Differences in the work of xml Mono serializers


What happens: the difference in the xml representation of the fields with the value null and the exception in the mono serializer when using empty namespace in xml.
As decided: Removed wcf service module "Documents" and replaced by webapi.

4. Memory leaks


What happens: a memory leak when using mod_mono_server for apache2. For example, when inserting new data into HttpRuntime.Cache with a key that is already in the cache, Mono, unlike .NET, does not free the memory occupied by the previous data.
What was the matter: still a mystery to us.
How did you decide: to solve this problem, you must explicitly delete old data before inserting new ones. We, in turn, switched to nginx, where there was no such problem.

5. NullReferenceException Exceptions


What happens: in the WCF service, when accessing the members of the ConfigurationManager class, a NullReferenceException occurred if we had previously overwritten the HttpContext.Current property somewhere.
What is the matter: if you manually set HttpContext.Current in a non-web application, then mono starts using WebConfigurationManager instead of ConfigurationManager, which leads to exceptions in a non-web application.
As decided: got rid of the installation manually HttpContext.Current.

6. Microsoft version incompatibility and HTTP WCF


What is the matter: HTTP WCF Mono service has many minor differences compared to the Microsoft version (for example, small differences in xml during serialization; in the mono version, extensions cannot be specified through attributes, only through the configuration file; there is no HttpContext.Current, and so on) .
As decided: rewrote HTTP WCF document service for a version based on Web API.

7. SignalR server crash during load testing


What's the matter: when messaging in a chat embedded in a page, we use the ASP.NET SignalR library. When porting ONLYOFFICE under Mono, we would like to use this library there as well. It supports several types of data transports: websockets, long polling, forever frame, server sent events. The most preferable for us is the technology of web sockets, which we use in our Saas version. Unfortunately, at the moment SignalR does not allow the use of websockets for Mono, so an attempt was made to use Long Polling as a transport. But at the stage of load testing, the SignalR server fell with the exception System.IO.IOException: “Too many open files” - after about a thousand client connections. Upon further investigation of the problem, a socket leak on the SignalR server was noticed after the client disconnect, which we reported to the SignalR developers. We hope in the next version of SignalR this problem will be solved.
As they decided: other transports are not suitable for solving our problems for various reasons, therefore at the moment for the version for Mono we had to disable the chat, which works through SignalR.

In total, several hundred changes were made to the project, however, as a result, we managed to make a version that, when building from the same source, works correctly under Windows and under Unix using Mono.

What we have in the end


Half a year has passed since the first ONLYOFFICE page was launched under Mono. Today we have a cross-platform solution for managing projects and documents, maintaining a customer base, enhanced by a mail aggregator and other collaboration tools.



As the copyright protection for our product, we have chosen the AGPL v.3 license , that is, you can deploy ONLYOFFICE Common for the team’s internal work, however, using the sources in your own project, you must open its code under the same license.

Docker Trend


Already a couple of hours after the release of the version, a message from an initiative user appeared on our developer forum , who was ahead of us and already managed to wrap the entire solution in the Dockerfile (for which we thank him very much).

Despite the fact that we still need to work with this assembly, the trend has been guessed correctly - in the near future we plan to prepare ONLYOFFICE Docker-container for each distribution language.

Online Document Editors for Linux - Coming Soon


Most of the ONLYOFFICE backend of document editors is written in C ++, so the translation of the application under Linux is done by other methods.

For example, we recently finished working with elements responsible for converting document formats. The main difficulty here is to get rid of ActiveX and ATL components.

To realize our plans, it was necessary to carry out four steps:

The nearest plans include the development of desktop office applications for popular OSs, so for the build we used qmake from the Qt Framework framework. In addition, IDE QtCreator seemed the most convenient option for developing and debugging code.

* * *

If we started developing the product today, of course, we would turn to ASP.NET vNext , which was announced just in time for the ONLYOFFICE porting process (about the unfair development world!). However, the matter has already been done, and the plans, as always, are Napoleonic. Next year we are launching an open online office for Linux, which means we can finally face off with OpenOffice on their own territory. However, this is a completely different story, which we will discuss in more detail in January.

In the meantime, our team wishes everyone a Happy New Year!
ps. Who is already on vacation with his soul, and with his body in the office, can pass the clock, counting all the penguins on the photo (our employees do not count;)

Source: https://habr.com/ru/post/246777/


All Articles