Chilkat IMAP service is stuck on 100% CPU after several days the Windows service that uses it executes normally. It is being reproduced every several days (3-7 days).
I'm using Chilkat IAMP for .NET 4.5 version 9.5.0 64-bit.
The way I abort through c# code is (it runs once on every end of iteration):
if (imapCon != null)
{
if (imapCon.IsLoggedIn())
{
imapCon.Logout();
}
if (imapCon.IsConnected())
{
imapCon.Disconnect();
}
imapCon.Dispose();
imapCon = null;
}
From the logs, I get: WSAECONNABORTED An established connection was aborted by the software in your host machine.
The service that runs it resides in a virtual cloud environment.
Is this an issue with how Chilkat IMAP connection is implemented, the cloud environment implementation or something from my service (the application that uses the Chilkat module)...?
The following are Chilkat logs:
DllDate: May 6 2014
ChilkatVersion: 9.5.0.38
UnlockPrefix: SNILIKIMAPMAIL
Username: WIN-OCJD4A0985E:SYSTEM
Architecture: Little Endian; 64-bit
Language: .NET 4.5 / x64
VerboseLogging: 0
listMailboxes:
bSubscribedOnly: 0 reference:
mailbox: *
Escaping quotes and backslashes in mailbox name...
utf7EncodedMailboxPath: *
getCompleteResponse:
WindowsError: An established connection was aborted by the software in your host machine.
WindowsErrorCode: 0x2745
numBytesRequested: 5
Failed to receive data on the TCP socket
Failed to read beginning of SSL/TLS record.
Failed to read incoming handshake messages. (3)
(leaveContext)
Client handshake failed. (3)
(leaveContext)
ConnectFailReason: 0
(leaveContext) failReason: 0
connect failed.
(leaveContext) Login:
DllDate: May 6 2014
ChilkatVersion: 9.5.0.38
UnlockPrefix: SNILIKIMAPMAIL
Username: WIN-OCJD4A0985E:SYSTEM
Architecture: Little Endian; 64-bit
Language: .NET 4.5 / x64
VerboseLogging: 0
login: **
ConnectionType: SSL/TLS
Error sending on socket (1)
SocketError: WSAECONNABORTED An established connection was aborted by
the software in your host machine.
For more information see this Chilkat Blog post:
http://www.cknotes.com/?p=91
send_size: 90
Failed to send TLS message.
Failed to send LOGIN command
Failed.
If a Chilkat method call never returns and utilizes 100% of the CPU, then you would not be able to get the contents of the LastErrorText (which is the Chilkat log you have provided). The fact that you have a LastErrorText indicates that the Chilkat method call has returned and your app then proceeded to display the LastErrorText.
My guess is that your app has a loop where normally a Chilkat method call involving communications with an IMAP mail server succeeds (with a normal amount of time spent communicating with the server), but then for some reason the method call begins returning immediately with a failed status. At that point, I suspect your application is probably in a tight loop calling the Chilkat method over and over. The 100% CPU utilization is likely caused by the loop in your app, NOT by code within a call to a Chilkat method.
Related
We have a big system with bunch of services communicating with each other via TIBCO EMS Messaging.
Now, one of the services keeps throwing this exception when it tries to connect to EMS server:
TIBCO.EMS.IllegalStateException: connect failed: server in standby mode
However, other services on the same EMS server are working just fine without any exception.
I tried to reproduce this by creating a console application which would use same credentials to connect to EMS server on the same destination (Queue) but couldn't reproduce this error.
EMS connection is fault-tolerant and it might have been failed over to secondary server, however, now I see primary server is back up.
I also tried to connect to primary server only (which I can see is up & running) but it fails with the same exception.
Below is the stack trace for reference:
TIBCO.EMS.IllegalStateException: connect failed: server in standby mode
at TIBCO.EMS.CFImpl._CreateConnection(String userName, String password, Boolean xa)
at TIBCO.EMS.ConnectionFactory.CreateConnection(String userName, String password)
at Ems.makeConn()
We're using TIBCO.EMS.dll v. 8.1.0.10 on .NET 4.0.
Any idea what can cause this exception ?
Could your connection string only mention one of the hosts inside an FT/HA setup ? This looks like the error message returned when you are trying to connect to only one of the HA/FT host, but not the one active at the moment.
If it is the case, the connection string will work most of the time, but a proper EMS HA connection string include two (or more!) EMS host and port. Only one is active at the same time.
It typically looks like this:
serverUrl=tcp://server0:7222, tcp://server1:7344
See source doc here in TIBCO docs.
It turned out tools we were using to check if server is active (we don't have admin rights on the servers) was misbehaving (showing incorrect status), so none of those servers were really active (not primary nor secondary).
As soon as server was brought up this error message went away.
I have two console applications, A and B.
The application A was created for test purposes and works as expected.
The application B does not work although it is basically a copy-paste of A's code:
System.Console.Write("User Name: ");
string username = System.Console.ReadLine();
System.Console.Write("Password: ");
string password = ConsoleReadPassword();
System.Console.WriteLine();
//user and password required because I am also a privileged user
//(member of mqm group)
MQEnvironment.UserId = username;
MQEnvironment.Password = password;
//for application B this line throws exception with code 2538
var queueManager = new MQQueueManager("TEST.QUEUE.MANAGER", "CLIENT.CONN.CHANNEL", "localhost(1414)");
Error code 2538 means "Host not available" which is weird because application A has no problems connecting to the same host.
This is how the MQ Server looks in MQ Explorer:
Queue managers:
Queues:
Listeners:
Channels:
Two server channels
Channel auth records:
Default channel authentication record which prevents MQ admins from connecting to queue managers. It was slightly modified (added ~ prefix) so now it does not block anyone.
The MQ Server and applications are running on the same machine so imho network problems are excluded.
The queue manager error log does not report any errors but the general error log looks like this:
08/02/2016 15:15:23 - Process(13720.10) User([username])
Program(B.EXE) AMQ9202: Remote host 'localhost(1414)' not
available, retry later.
EXPLANATION: The attempt to allocate a conversation using TCP/IP to
host 'localhost(1414)' for channel (Exception) was not successful.
However the error may be a transitory one and it may be possible to
successfully allocate a TCP/IP conversation later.
For both application I use the same version of amqmdnet.dll: 8.0.0.4
Both programs A and B have the same target framework: 4.5
While testing I didn't tried to run the both applications in the same time and I checked in MQ Explorer if the channel is free (Inactive).
I also tried to change the name of resulting assemblies but with no effect.
Does anyone know what could cause application B to be unable to connect?
When using the hostname localhost networking is still involved, it just all happens inside the one machine. If application A is running in the same machine as your queue manager then having application A connect using the connection name localhost(1414) will certainly work but it is not necessary to make the connection like this (i.e. using TCP/IP) you could instead make a local bindings connection.
On the other hand, if you are using TCP/IP because application B is running on a different machine to where the queue manager is running, then using localhost(1414) will not work because localhost on one machine does not connect to localhost on another machine. You should change what is specified in the application's connection name from localhost(1414) to use the IP address (or hostname) of the queue manager's machine (followed as before with the port number).
Although I was unable to find the cause of the problem the solution was to simply
delete and re-create the project.
This is what I tried before and what led me to this action:
In B I removed and then added back the reference to amqmdnet.dll - not working
I created yet another project (let's call it C): console application, same code - working
I renamed* the C project with the same name as B - still working
*The name of the non-working project contained a dot so I thought that this could cause the problem - it was not the case.
I'm having a weird trouble with OpenSSL in C#.
Facts: I've programmed a wrapper for C# that is working completely fine, it could connect to other SSL servers, or accept connections from SSL clients. My wrapper is using memory BIO's only. Anytime I connect the MEM BIO to in and outputs of any type socket of socket handshake is successful, data transfer is working, so the problem is not in the wrapper.
I've made two programs with this wrapper, a client and a server, they estabilish the ssl session, and when I try to send data from the server to the client (or opposite way) and the other side echoes it back to the sender for some reason the data traffic is very slow (max 20kB/s even in local loopback, if I try send with higher speed like pumping more data in the SSL_read() then with TLS on TCP there are huge delays, with DTLS on UDP there is sometimes 75% of packet loss), so i've decided to benchmark the OpenSSL with the wrapper, because some methods or wrong parameters may slow down the running.
My idea was to init two SSL contexts in one program, one client and one server, connect they Memory BIO's to each other (RX-TX TX-RX), and start a handshake.
I just can't make them finish the handshaking successfully!
With DTLS1 after Clienthello, the server starts to respond with Serverhello and Cert data in 4 packets (3x256 bytes + 145), but after the first packet the client alerts:
After writing to CLIENT (packet: 2): 22016:error:14102044:SSL routines:dtls1_read_bytes:internal error:.\ssl\d1_pkt.c:1370:
After writing to CLIENT (packet: 3): 22016:error:14102044:SSL routines:dtls1_read_bytes:internal error:.\ssl\d1_pkt.c:1370:
After writing to CLIENT (packet: 4): 22016:error:14102044:SSL routines:dtls1_read_bytes:internal error:.\ssl\d1_pkt.c:1370:
After writing to CLIENT (packet: 5): 22016:error:14102044:SSL routines:dtls1_read_bytes:internal error:.\ssl\d1_pkt.c:1370:
The packet flow between the two sessions is the following:
Client -> 178 -> Server
Server -> 256 -> Client
Server -> 256 -> Client
Server -> 256 -> Client
Server -> 145 -> Client
Client -> 15 -> Server
I've analyzed these packets (after file dump) with Wireshark, and everything seems OK (this analysis is not of the packets above, but same reproduction of the problem):
http://reset.tor.hu/ssl/sima/programom_dtls1.txt
After this i get more errors:
After writing to SERVER (packet: 5): 22016:error:141020E5:SSL routines:dtls1_read_bytes:ssl handshake failure:.\ssl\d1_pkt.c:819:
Before writing to SERVER (packet: 6): 22016:error:140FD10F:SSL routines:DTLS1_GET_MESSAGE_FRAGMENT:bad length:.\ssl\d1_both.c:892:
After writing to SERVER (packet: 6): 22016:error:14102417:SSL routines:dtls1_read_bytes:sslv3 alert illegal parameter:.\ssl\d1_pkt.c:1200:SSL alert number 47
22016:error:141020E5:SSL routines:dtls1_read_bytes:ssl handshake failure:.\ssl\d1_pkt.c:819:
My only usable idea was to debug this problem to dump the packets to files right after they have been read from the BIO and right before they get written in the BIO in the other session, but I've found no any difference in the content after byte-comparison, and the packet sequence was OK, too.
File dumps are here: http://reset.tor.hu/ssl/y/direct_bio_error/
I just couldn't imagine what could be the problem because they have never finished handshake without failure, so I've decided to add two UDP sockets to this program, and connect the sockets to the BIO's and to each other, and not surprisingly the handshake was successful for the first time.
File dumps are here: http://reset.tor.hu/ssl/y/socket_ok/
As it is visible there is nothing difference in the file contents or the packet sequences.
Then why are they not working with BIO's directly connected?!
You can see the program producing the error and the normal working in this video: https://www.youtube.com/watch?v=4crbSz6JMMY
My only idea was C# for some reason mixing the method calls in the time but i'm not using any threading! The unmanaged code calls a callback to read out BIO, I read out BIO to my buffer, I call another method that writes the buffer in the BIO and call SSL_read() in the unmanaged code, to use the data in the BIO. And this is exactly in the other way. If i'm not using the buffer, but the sockets instead it's working. What the sockets can do that makes it working?
I've even tried to put Thread.Sleep(100) between the BIO writings, but didn't help, actually over 140ms OpenSSL crashed (but with sockets it worked even with 1000ms, even more weird).
What could be the problem and solution for the direct BIO and the slow traffic problem?
Thank You for the answers in advance!
Ok, actually it seems i have just solved the Direct-Memory-BIO-Handshake problem.
It is suggested to call SSL_read() after BIO_write(), otherwise OpenSSL won't check for data in the READ BIO and will not process it, so almost everytime people use it directly after writing to BIO.
If one configured the OpenSSL context as CLIENT then one should NOT use SSL_read() after BIO_write() directly until handshaking not finished!
If OpenSSL is used with socket (even with memory bio's) it is working if we use SSL_read() directly after BIO_write(), but with direct BIO connection between two sessions NOT. At least as unmanaged code in C#!
The BIO writing method that works fine is the following:
public bool BIO_Write(byte[] data)
{
if (Inited & data.Length > 0)
{
Wrapper.BIO_write(BIOR, data, data.Length);
if (isServer(SSL_method))
{
// For SERVER MODE
if (Wrapper.SSL_is_init_finished(SSL))
{
readFromSSL();
}
else
{
Wrapper.SSL_do_handshake(SSL);
}
}
else
{
// For CLIENT MODE
if (Wrapper.SSL_is_init_finished(SSL))
{
readFromSSL();
}
else
{
// It is extremely important to call the SSL_do_handshake()
// only if SSL_want() returns 3, otherwise OpenSSL will
// throw a FATAL ERROR and crash with direct BIO connection
// return value 3 is SSL_ERROR_WANT_WRITE
if (Wrapper.SSL_want(SSL) == 3)
{
Wrapper.SSL_do_handshake(SSL);
}
}
}
return true;
}
else
{
return false;
}
}
I hope this will help someone!
These errors are getting more and more frequent on my Game Server. They are causing the server to keep closing and restarting...
System.Net.Sockets.SocketException (0x80004005): An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.BeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
at iRP.Game.Sessions.Session.SendData(Byte[] Data)
This is the code from which these errors are generated:
public void SendData(byte[] Data)
{
try
{
if (mSocket == null)
{
//Output.WriteLine("[SND] Socket has a null exception, which means it is now invalid. Remove this socket!", OutputLevel.CriticalError);
}
else
{
mSocket.BeginSend(Data, 0, Data.Length, SocketFlags.None, sendCallback, mSocket);
}
}
catch (Exception e)
{
string WhatToWrite = "Error handled (SESSION): " + e.ToString() + "\n\n" + e.Message + "\n\nStack: " + e.StackTrace + Environment.NewLine + "\n\n";
File.AppendAllText(Environment.CurrentDirectory + "\\data\\fatal.txt", WhatToWrite);
Program.Stop();
}
}
The buffer sizes are correctly set, we are using KeepAlive on the socket and were using Send and Receive Timeouts.
People suggested that disabling the firewall would help, but whenever I do this our Game Server (Dedicated Server) restarts itself as if it's under attack, so the firewall must remain enabled.
Anyone else got any other solutions for this?
PS: We are behind DDoS Mitigation Services which may be limiting the number of connections...
An established connection was aborted by the software in your host machine
That is a boiler-plate error message, it comes out of Windows. The underlying error code is WSAECONNABORTED. Which really doesn't mean more than "connection was aborted". You have to be a bit careful about the "your host machine" part of the phrase. In the vast majority of Windows application programs, it is indeed the host that the desktop app is connected to that aborted the connection. Usually a server somewhere else.
The roles are reversed however when you implement your own server. Now you need to read the error message as "aborted by the application at the other end of the wire". Which is of course not uncommon when you implement a server, client programs that use your server are not unlikely to abort a connection for whatever reason. It can mean that a fire-wall or a proxy terminated the connection but that's not very likely since they typically would not allow the connection to be established in the first place.
You don't really know why a connection was aborted unless you have insight what is going on at the other end of the wire. That's of course hard to come by. If your server is reachable through the Internet then don't discount the possibility that you are being probed by a port scanner. Or your customers, looking for a game cheat.
This problem appear if two software use same port for connecting to the server
try to close the port by cmd according to your operating system
then reboot your Android studio or your Eclipse or your Software.
Could be related to the maximum number of concurrent requests. I was able to fix it with two solutions:
Increase the default limit of the max concurrent connections (by default it is set to 2):
ServicePointManager.DefaultConnectionLimit = 25
Wrap sending requests around a buffer: could use ConcurrentQueue to limit the rate, or implement a simple wait as the following:
while (activeRequests >= maxConcurrentRequests)
Thread.Sleep(1000);
Interlocked.Increment(ref activeRequests);
var response = await _client.GetStreamAsync(endpoint);
Interlocked.Decrement(ref activeRequests);
While the answer from Hans is an excellent high level summary of the error that worked great for getting me started, I ended up finding a page that explained the root cause well enough that I was able to recreate it with a python script.
The page presents a couple different descriptions of this error that are more detailed than the "connection was aborted" paraphrasing from Hans's answer but still pretty cryptic and not very informative.
The post then explains this scenario that would produce the error:
An HTTP POST is to be sent to an HTTP server.
The server begins reading the POST and notices that the HTTP request header is invalid.
It immediately sends an HTTP response (with an error status, perhaps status=400) and closes the connection without trying to continue reading the remainder of the HTTP request that is forthcoming.
Meanwhile, the client is still happily writing the remainder of the HTTP request to the socket. (Remember a TCP/IP socket connection needs to be closed from both sides. In this case, the server has closed its side, but the client is still pumping data into the half-open connection.)
The client finishes writing the HTTP POST to the socket — meaning that data has been buffered to Winsock. The client application then tries to read the HTTP response, but it cannot because the outgoing retransmission (of the buffered data by WinSock) failed and the socket connection was shutdown on the client side (by Winsock). Even though the HTTP server sent the response, it is lost and cannot be retrieved. The error your application will receive when trying to read the HTTP response on the socket is WSAECONNABORTED
Wikipedia also has a page to explain what winsock is, but all you really need to know for this scenario is that its the Windows socket API.
I had "ManageEngine Agent" installed on my computer, which was blocking my connection to the databases, so uninstalling it was the solution.
Check which application could block the connection to your DB.
I am trying to connect to a remote queue using c#.
I tried many ways to connect to the remote queue but it always fails with common errors like: MQRC_CHANNEL_CONFIG_ERROR or MQRC_HOST_NOT_AVAILABLE.
What I am doing is this:
string channel = "QM_TEST.SVRCONN";
string hostname = "<serverIp>";
string queueName = "QM_TEST";
string port = 1414;
props.Add(MQC.HOST_NAME_PROPERTY, hostname);
props.Add(MQC.CHANNEL_PROPERTY, channel);
props.Add(MQC.PORT_PROPERTY, port );
props.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
MQQueueManager mqQueue = new MQQueueManager(queueName, props);
I have tried changing this but all failed.
I think that my problem is the server configurations..
can you point me to a full guide to how to configure a server and connect to it with .net?
My problem is connecting to a REMOTE server using .net and not to a local server.
Thank you!
The problem was that the CCSID between the client and the server were different.
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.csqzaf.doc%2Fcs12480_.htm
On the client side I had to put
Environment.SetEnvironmentVariable("MQCCSID", "437");
Thats why I got:
MQRC_CHANNEL_CONFIG_ERROR
I'm guessing the problem (or at least a problem) is here:
MQQueue mqQueue = new MQQueueManager(queueName, props);
This should be
queueManager = new MQQueueManager(queueManagerName, properties);
If you have installed the WebSphere MQ client to the default location, there are many sample programs under the following directory:
C:\Program Files (x86)\IBM\WebSphere MQ\tools\dotnet\samples\cs\base\
There are a number of sample programs there for various tasks. If you have the latest V7.1 client installed then you will see the following programs:
SimpleAsyncPut
SimpleClientAutoReconnectGet
SimpleClientAutoReconnectPut
SimpleGet
SimpleMessageProperties
SimplePublish
SimplePut
SimpleReadAhead
SimpleSharingConversation
SimpleSubscribe
SimpleXAGet
SimpleXAPut
There are also WCF and XMS samples.
If you need the client code, please see my response to another SO question here for links.
Update:
Here's the normal diagnostic process.
If the WMQ components were installed by relocating libraries or classes from somewhere else, perform an install using the full vendor-supplied client media. This includes troubleshooting utilities such as trace, dspmqver, etc. It also resolves any library or class mismatch issues.
Use the pre-compiled client programs to test the connection. The amqsputc, amqsgetc and amqsbcgc programs require the MQSERVER environment variable as described here. The Q program from SupportPac MA01 is a separate download but has the advantage of NOT requiring any environment variables, CCDT files or other dependencies.
If the sample programs fail, check the QMgr's error logs at [WMQ install]/qmgrs/[QMgr name]/errors/AMQERR01.LOG for messages. Also check for FDC files and errors in [WMQ install]/errors.
If no errors on the QMgr side, attempt the connection again while using a client-side trace as described here and here.
Most client problems are resolved through installation of the full WMQ client as supplied by IBM. (Conversely that implies most people are installing by grabbing DLL or JAR files.) If the problem persists, error log inspection on the QMgr and client side usually reveals the underlying cause. If these do not work then tracing usually diagnoses the remaining issues.
UPDATE 2:
Per the error messages posted at MQSeries.net, the channel has a security exit set. A security exit is external code that the channel calls out to when starting a channel. There is no way to know what the exit expects or does without having access to the code or docs of the exit. If the exit is written in-house, you'll need to talk to the programmer to figure out what it requires. If the exit is a commercial product then you will need to get the documentation for it.
Alternatively, alter the channel so that SCYEXIT is blank to disable the exit.
The data posted at MQSeries.net was as follows:
MQ9575: DCE Security: failed to get the user's login name.
EXPLANATION:
System call 192.168.50.55 to get the login name of the user running WebSphere
MQ client application process 5 failed with error value -1. This occurred in
security exit function create_cred. The exit will now attempt to open channel
using the DCE default login context.
ACTION:
If you wish to run using the DCE default login context take no action. If you
wish to run using the user's login name as the DCE security exit principal
examine the documentation for the operating system on which you are running MQ
clients and reconfigure the operating system as necessary to allow the
192.168.50.55 call to succeed.
Note that it states the call is failing in the security exit.