0 votes
by (150 points)

Hi, I have a couple of questions about the Rebex Syslog Client:

  • Is the SyslogClient thread safe. Is it possible to create one instance of the client in my web application and use it for all the incoming http requests?
  • Does the SyslogClient ensure that the connection stays open? Is it reconnecting if the TCP connection drop?
  • I would like to use the SyslogClient to send audits to a SyslogServer. So I want to be sure that when I use the client, that the message was received by the SyslogServer. If it's not possible to send the message, I would like the client to throw an exception. Is it possible with your SyslogClient?
  • Does the SyslogClient have a kind of connections pool to connect to the SyslogServer, to load balance the logs to send? Let say I have 100 logs to send simulatinously from 100 different http request.
Applies to: Syslog

1 Answer

0 votes
by (62.7k points)
selected by
 
Best answer
  • Is the SyslogClient thread safe. Is it possible to create one instance of the client in my web application and use it for all the incoming http requests?
  1. The SyslogClient internals are synchronized. It means you can call Connect(), Send() and Close() methods from different threads without corrupting internal state. However, for example calling Send() before completing Connect() will throw an exception.

  2. The SyslogClient can use plain TCP or TLS protected connections (see SyslogTransportProtocol). In case of TLS you will receive an error if you try to call Send() simultaneously. For plain TCP connections the Send() calls are not synchronized, they are delegated to the underlying system Socket, which means the thread-safety depends on Socket.Send() implementation.

  • Does the SyslogClient ensure that the connection stays open? Is it reconnecting if the TCP connection drop?
    No.

  • I would like to use the SyslogClient to send audits to a SyslogServer. So I want to be sure that when I use the client, that the message was received by the SyslogServer. If it's not possible to send the message, I would like the client to throw an exception. Is it possible with your SyslogClient?
    Yes, the Send() method throws an exception (typically SocketException or TlsException) on failure. However, if no exception is thrown it only means that the underlying network system successfully accepted data to be sent over the network, it does not ensure that the server have received and stored the Syslog message for auditing.

  • Does the SyslogClient have a kind of connections pool to connect to the SyslogServer, to load balance the logs to send? Let say I have 100 logs to send simulatinously from 100 different http request.
    No.


It seems that Producer-Consumer pattern is very suitable for your scenario:

  • HTTP requests will be producers. They will store audit messages in a blocking collection.
  • 1 or more "sender" threads will be consumers, each having its own SyslogClient instance. Consumers will take messages from blocking collection and send them sequentially. If Send() fails, the consumer simply discards the failed connection, creates new SyslogClient, connects to the Syslog server and sends the failed message again.

The BlockingCollection can be very useful to implement this solution.

...