Why does syslog4j ignore certain messages? - syslog

I use syslog4j (current version from 2011) to receive syslog messages. Obviously some of them are not processed and I can see using wireshark that they leave the originating server and arrive on my server which runs the syslog4j program.
Unfortunately I am limited to using syslog with udp as this is the only configuration the sender supports. But as I can see the packets in the wireshark this does not seem to be the cause of the problem.
My program looks like this:
SyslogServerIF syslogServer = SyslogServer.getInstance("udp");
SyslogServerConfigIF syslogServerConfig = syslogServer.getConfig();
syslogServerConfig.addEventHandler( new MyEventHandler());
SyslogServer.getThreadedInstance("udp");
while (true) {
SyslogUtility.sleep(1000);
}
My (abbreviated) version of the Handler is written this way:
public class MyEventHandler implements SyslogServerSessionEventHandlerIF {
public void event(Object session, SyslogServerIF syslogServer,
SocketAddress socketAddress, SyslogServerEventIF event) {
System.out.println("event.msg : " + event.getMessage());
System.out.println("event.date: " + event.getDate());
}
}
There is no high load on the application (about 100 messages in 5 minutes) but 10 to 20% of the messages are lost

Related

Close Connection on SessionClient - AWS Neptune

I use aws-neptune.
And I try to implement my queries as transactional(with sessionClient like: https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-sessions.html). But when I try to implement it, closing client throws exception. There is similar issue like my case: https://groups.google.com/g/janusgraph-users/c/N1TPbUU7Szw
My code looks like:
#Bean
public Cluster gremlinCluster()
{
return Cluster.build()
.addContactPoint(GREMLIN_ENDPOINT)
.port(GREMLIN_PORT)
.enableSsl(GREMLIN_SSL_ENABLED)
.keyCertChainFile("classpath:SFSRootCAG2.pem")
.create();
}
private void runInTransaction()
{
String sessionId = UUID.randomUUID().toString();
Client.SessionedClient client = cluster.connect(sessionId);
try
{
client.submit("query...");
}
finally
{
if (client != null)
{
client.close();
}
}
}
And exception is:
INFO (ConnectionPool.java:225) - Signalled closing of connection pool on Host{address=...} with core size of 1
WARN (Connection.java:322) - Timeout while trying to close connection on ... - force closing - server will close session on shutdown or expiration.
java.util.concurrent.TimeoutException
at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1771)
Is there any suggestion?
This might be a connectivity problem with the server which you are not able to observe while sending the query because you are not waiting for the future to complete.
When you do a client.submit("query...");, you receive a future. You need to wait for that future to complete to observe any exceptions (or success).
I would suggest the following:
Try hitting the server with a health status call using curl to verify connectivity with the server.
Replace the client.submit("query..."); with client.submit("query...").all().join(); to get the error during connection with the server.

Monitor the "active state" of Biztalk send port service instance

Team,
My biztalk send port instance gets hung and stays in the active state for longer periods of time. I would like to monitor that send port active instance with the help of C#.
I intend to run a code which will check if the send port(passed as a parameter) is still in a running state or not. Can anyone help me with that piece of code ?
Use WMI MSBTS_ServiceInstance.ServiceStatus Property:
public static int GetRunningServiceInstanceCount()
{
int countofServiceInstances = 0;
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer", "SELECT * FROM MSBTS_ServiceInstance WHERE ServiceStatus = 1 or ServiceStatus = 2");
countofServiceInstances = searcher.Get().Count;
return countofServiceInstances;
}
catch (ManagementException exWmi)
{
throw new System.Exception("An error occurred while querying for WMI data: " + exWmi.Message);
}
}
To get to your actual problem: The SFTP adapter in BizTalk 2016 has a great way of using the most recent version of the FTP code. This might solve stability issues.
Assuming from your BizTalk 2013 tag, you're probably not using the 2016 version, in that case double check you are at least at CU3 since that one solves a few critical SFTP bugs.

What if only send without recv in my Thrift client?

I'm implementing a Thrift client in order to make connection to a built-in scribe server.
Everything is going OK if I use a standard Log method, like this:
public boolean log(List<LogEntry> messages) {
boolean ret = false;
PooledClient client = borrowClient();
try {
if ((client != null) && (client.getClient() != null)) {
ResultCode result = client.getClient().Log(messages);
ret = (result != null && result.equals(ResultCode.OK));
returnClient(client);
}
} catch (Exception ex) {
logger.error(LogUtil.stackTrace(ex));
invalidClient(client);
}
return ret;
}
However, when I use send_Log instead:
public void send_Log(List<LogEntry> messages) {
PooledClient client = borrowClient();
try {
if ((client != null) && (client.getClient() != null)) {
client.getClient().send_Log(messages);
returnClient(client);
}
} catch (Exception ex) {
logger.error(LogUtil.stackTrace(ex));
invalidClient(client);
}
}
It acctually causes some problems:
Total network connection to port 1463 (default port for a scribe server) is going to increase so much, and always in a CLOSE_WAIT state.
Cause my application got stuck without throwing any error, I think it may be an issue with network connection.
what if send without recv
As this is clearly TCP, the sender will block (in blocking mode), or incur EAGAIN/EWOULDBLOCK in non-blocking mode. EDIT It is now clear that you want to send without receiving the reply. You can do that by just sending and then closing the socket, but that may cause the peer to incur ECONNRESET, which may upset it. You should really implement the application protocol correctly.
1/ Total network connection to port 1463 (default port for a scribe server) is going to increase so much, and always in a CLOSE_WAIT state.
Lots of ports in CLOSE_WAIT state indicates a socket leak on the part of the local application.
2/ Cause my application got stuck without throwing any error. I think it may be an issues with network connection.
It is an issue with sending and not receiving.
Since you labelled this as a Thrift related question, the answer is oneway.
service foo {
oneway void FireAndForget(1: some args)
}
The oneway keyword does exactly what the name suggests. You get a client implementation that only sends and does not wait for anything to be returned from the server. This rule also includes exceptions. Hence a oneway method must always be void and can't throw any exceptions.
However, when I use send_Log instead ...
client.getClient().send_Log(messages);
Neither one of the Thrift-generated send_Xxx and recv_Xxx methods are meant to be public. That's why they are usually either private or protected methods. They should not be called directly, unless you are sure that you know what you are doing (and very obviously the latter is not the case here).
And since the real question is about performance: Why don't you just delegate the call(s) into a secondary thread? That way the I/O will not block the UI.

SSLSocketFactory.createSocket connects using http instead of https

I need to make a handshake. I do it with the code below.
I'm running the code in an applet and it works fine when running directly against the server. The problem I have occurs when the same code runs via a proxy.
I'm looking in the java console with trace level 5 activated. Directly after the code line "SSLSocket socket = (SSLSocket) factory.createSocket("www.theserver.com", 443);" is executed
this line appears in the java console "network: Connecting http://www.theserver.com:443 with proxy=DIRECT". After this the applet stops working. I think it is because the
proxy will not allow http traffic on port 443.
Can anyone tell me why it is connecting using http and what I should do to make it connect using https?
import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
public class Handshake
{
class MyHandshakeListener implements HandshakeCompletedListener
{
public void handshakeCompleted(HandshakeCompletedEvent e)
{
System.out.println("Handshake succesful!");
System.out.println("Using cipher suite: " + e.getCipherSuite());
}
}
public void DoHandshake()
{
try
{
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) factory.createSocket("www.theserver.com", 443);
String[] suites = socket.getSupportedCipherSuites();
socket.setEnabledCipherSuites(suites);
socket.addHandshakeCompletedListener(new MyHandshakeListener());
socket.startHandshake();
}
catch (Exception e)
{
System.out.println(e);
}
}
}
I know this is a little late, but we had the exact same problem and was just able to resolve it. The problem was on the client, the "Use SSL 2.0 compatible ClientHello format" was checked on the advanced tab of the Java Control Panel. Uncheck this box on the client and it will connect correctly.

How SignalR works internally: client side

I'm writing my own SignalR Client on Java and I'm facing some troubles.
At first I want to implement PersistentConnection logic. My server code is taken from example:
public class Battle : PersistentConnection
{
protected override Task OnConnectedAsync(IRequest request, string connectionId)
{
return Connection.Broadcast("Connection " + connectionId + " connected");
}
protected override Task OnReconnectedAsync(IRequest request, IEnumerable<string> groups, string clientId)
{
return Connection.Broadcast("Client " + clientId + " re-connected");
}
protected override Task OnReceivedAsync(IRequest request, string connectionId, string data)
{
// return Connection.Broadcast("Connection " + connectionId + " sent ");
return Connection.Send(connectionId, "Connection " + connectionId + " sent ");
}
protected override Task OnDisconnectAsync(string connectionId)
{
return Connection.Broadcast("Connection " + connectionId + " disconncted");
}
protected override Task OnErrorAsync(Exception error)
{
return Connection.Broadcast("Error occured " + error);
}
}
Judging by .NET client code, I understood that in order to connect to server client should:
1) Send request to http://myserver/battle/negotiate and get ConnectionId from response
2) Send request to http://myserver/battle/connect?transport=longPolling&connectionId=<received_connection_id>
My question is waht should client do to maintain connection? How should it listen to server broadcasting messages?
Another issue is that I receive no response when I'm trying to send message from client to server after connection has been established. I send request to http://myserver/battle/send?transport=longPolling&connectionId=<received_connection_id>. Method OnReceivedAsync is always called, but I get no response (independently of data sent).
I'd be grateful for any explanations on my questions and on internal principles of SignalR work.
Thanks in advance.
I've tried to do the same thing that you are doing! I've implemented a SignalR-client for Android and I called it SignalA. :) Have a look at it on github.
There are several methods of communication used in SignalR. My understanding is that SignalR will use the best one it determines will work with the given connection.
The general idea behind long polling is this: The client sends a request to the server with a long timeout period. Say 2 minutes or 5 minutes. If the server has a message to send to the client, it then responds to the client request with the message. Otherwise the request will eventually timeout, at which point the client initiates a new request. So, basically, the client is nearly always in a call to the server. The server only ever answers when it has a message for the client. So the client could send the request to the server and say, 90 seconds later, the server gets a message for the client.
For more information, read the Long Polling section of this Wikipedia article: http://en.wikipedia.org/wiki/Push_technology
But for the specifics, you really need to examine the .NET code closely. Hopefully this overview will give you enough to understand what's going on there, though.

Resources