phax / as2-server

A standalone Java AS2 server - see as2-lib for the generic parts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

configuration glitches and enhancement query/requests

etosan opened this issue · comments

Hello,

one of my clients requested to get this running as sideproject. After some time spent with this "thing" (as2 server) I am finally beating it into submission. As is usual for majority java software, it was quite hard to "deduce" how to use this, and documentation is suffering from slight malnutrition.

I am testing this in standalone mode, and already hit several glitches.

First, things I would like to request:

  • alias %home% config variable with %confdir%, with intention to deprecate %home% for config dir (the one that contains config.xml) use
  • some time after deprecation (a year?) use %home% to represent actual homedir of user under which process runs
    • or make this toggleable in config (I would rather not)?

I spent inordinate amount of time on this, until I found document @ http://openas2.sourceforge.net
where it is described that %home% actually means dir hosting config.xml. This is rather unfortunate choice.

Second thing I have problem with is certain attribute values and also generated filename mangling.
Let's say I have something like this:

    <module classname="com.helger.as2lib.processor.receiver.AS2ReceiverModule"      
            port="5555"
            errordir="errors"
            errorformat="$date.YYYY-MM-DD@HH:mm:ss.SSSS$,ip:$msg.attributes.source_ip$,msgid:$msg.headers.message-id$,sndr:$msg.sender.as2_id$,rcvr:$msg.receiver.as2_id$"/>

I guess due to Windows protection, all : in generated names are mangled into _. This is very unfortunate on non windows platforms, that are perfectly capable of handling such cases.

Second thing is that in IP attributes, like $msg.attributes.source_ip$, the attribute is actually prefixed with / char, eg. attribute value is literally /127.0.0.1. I don't understand reason for this, but it has quite a real effect when using such value in name generators. It makes server put files into subdirectories unintentionally, which is quite a sad behavior.

I looked at the code a bit, but it's quite complicated and hard to follow, but I guess it's normal for java.

As I will probably have to support solution based on this a long time, I have interest in having these issues fixed. Can these issues be fixed on your side?

Dear Martin, thanks for your comments and input.
as2-server is a software component I'm not using on my own. What I did was to take OpenAS2, extract the reusable components into as2-lib and go with them. This standalone server that comes with its own socket handling is imho a bad choice.
Instead I suggest you look at the as2-servlet subproject of as2-lib that offers the possibility to include all this into a WAR file to be used with common application servers like Tomcat or Jetty.

I try to respond to all of your errors one by one:

  • Concerning the documentation - any PR is welcome :) Some information on the configuration file can also be found at https://github.com/phax/as2-lib#as2-configuration-file
  • Masking of : - yes you are correct, there is an unconditional masking. The following characters are forbidden: { 0, '<', '>', '?', '*', ':', '|', '"' }. To my understanding ":" is the only character in question here - correct?
  • The field source_ip uses socket.getInetAddress().toString to determine its content. I can see the issue. It tries to do hostname/ip having an empty hostname, it ends up as /ip. I fixed this to use the IP address only. Thanks for pointing it out. Fixed in as2-lib 4.0.1

hth, Philip

Hello again,

first thank you for quick reply and the fix! I will follow same text structure as you did.

I understand the genesis of the project somewhat and I am really thankful you took over the maintainership. Regarding standalone as2-server I am becoming relatively content with it, I got it running under proper supervision with it's own posix account, logging and everything.
My clients, including this one, are mostly php shops, so running this standalone in a VM is best option for them. I mean I have only vague understanding of servlet capable server ecosystems (using WAR files) and never bothered managing Tomcat, Jetty (or some else instance). I don't have time currently to dive deep into Jetty or Tomcat. With Tomcat, we would be running big application server I don't know how to configure and mange, whose sole purpose would be AS2 processing. From my point of view running it standalone is both more efficient and manageable for us. We expect only reasonably low AS2 traffic, and in worst case I intend to prefix as2-server instance with nginx. Firewall rules allowing only certain partners to connect are already in place.

Still, I would like to know, why is relying on as2-server own socket management such a bad choice, in your opinion?

Next I will revisit errors in same order:

  • Regarding docs is it okay to edit github wiki pages?
  • Hmm regarding :, although modern unices allow almost all characters in filenames except 0 and /, I guess these few {'<', '>', '?', '*', '|', '"' } could be all confusing for inexperienced user. Still ':' is often used by, for example, Maildir format (servers like dovecot,courier etc). Thinking about it more, I would suggest excluding only ':' from the mangling list, and only if software is running on unix-like platform. Would that be doable from Java?
  • After some fighting with maven (I cloned current as2-lib master from github.com, built it and modified pom.xml to use as2-lib-parent-pom 4.0.1-SNAPSHOT) and it seems the changes you did went in. I can confirm that I now see files being formed with IP related attributes properly (no subdirs). Of course ':' are still mangled but that depends on previous error.

Great, we're moving on :)

  • Concerning Tomcat/Jetty fine for me - I was just pointing out opportunities. I'm not a socket expert so I personally prefer to hand this over to components that know what they are doing :) But no worries - I did not do any major changes to it and it is working without problems. Having the possibility to add an nginx in between would be good for throttling if necessary.
  • Concerning the docs - I will setup a Wiki space - fine for me. Thanks.
  • Concerning the : in filenames: I will create an exception that this is only considered on Windows OSs. That takes some time because it is in the base-base library (ph-commons) which has not too many release cycles but needs an update for Java 9 soon anyway.
  • Concerning the other fix: stay tuned, I will be the respective 4.0.1 releases so that you can use something stable "out of the box".

Hello again!

I see this went in and would like to try it. What do I need to do?

I need to release as2-lib 4.0.1 and as2-server 4.0.1 - than you have a release. Give me an hour please

No problem!

Take your time. I was hoping getting instructions on how to actually rebuild ph-commomns but I have no problem waiting till this gets in.

as2-server 4.0.1 release is on Maven Central within the next half hour. Enjoy

Thank you very much!

Seems all issues I hit are fixed for now.

If you find more - just let me know 😃