Server object error 'ASP 0177 : c0000005' - mysql

The full error:
The CreateObject of '(null)' caused exception C0000005.
Server object error 'ASP 0177 : c0000005'
Server.CreateObject Failed
/get.asp, line 35
get.asp - line 35:
Response.Status = "500 Internal Server Error"
set objErr=Server.GetLastError()
Col = objErr.Column
Cat = objErr.Category
Desc = objErr.Description
Fle = objErr.File
Lne = objErr.Line
Num = objErr.Number
Src = objErr.Source
ASPC = objErr.ASPCode
ASPD = objErr.ASPDescription
set SQLCOMM = Server.CreateObject("ADODB.Command") //line 35
SQLCOMM.ActiveConnection = DBConn_Str
SQLCOMM.CommandText = SQLq
SQLCOMM.CommandType = 1
SQLCOMM.CommandTimeout = 0
SQLCOMM.Prepared = true
SQLCOMM.Execute()
set SQLCOMM=Nothing
This script usually works, but for some odd reason it keeps giving this error every now and then lately. The most recent thing i did is make more table/col indexes in the MsSql DB, and i'm not sure why this is now happening. Does anybody know why?

The error is a windows Access Denied error. However what it disturbing is that it is an exception C00000005 rather than an error 80070005. Somewhere between CreateObject and the completion of initialising an ADODB.Command an access denied exception is being raised that isn't caught by normal means.
At this point in code the only thing being "accessed" is the ADODB.dll however its unlikely that this is truely a permissions problem. However if you are using windows integrated security on the site it my be worth seeing if there is a corelation between occurances and the user using the site.

Related

Selenuim, WebDriver: SessionNotCreatedException: "errorMessage": "Message: session not created: Missing or invalid capabilities"

So I am using chrome driver version 103.0.5060.53 and chrome version 103.0.5060.114 running on an ECR image based on public.ecr.aws/lambda/python:3.9-x86_64. The error that I am getting with the first code is "errorMessage": "Message: session not created: Missing or invalid capabilities\n (Driver info: chromedriver=103.0.5060.53 (a1711811edd74ff1cf2150f36ffa3b0dae40b17f-refs/branch-heads/5060#{#853}),platform=Linux 5.10.16.3-microsoft-standard-WSL2 x86_64)\n", "errorType": "SessionNotCreatedException"
chrome_opts = Options()
chrome_opts.add_argument("--allow-running-insecure-content")
if 'DOCKER_AUTH_CONFIG' in os.environ:
chrome_opts.add_argument('--headless')
chrome_opts.add_argument('--no-sandbox')
chrome_opts.add_argument('--disable-dev-shm-usage')
self.headless = True
chrome_opts.add_argument("window-size=1920,1080")
chrome_opts.binary_location = '/usr/bin/google-chrome'
chrome_opts.add_experimental_option('w3c', False)
desired_cap = {}
desired_cap['platform'] = 'ANY'
desired_cap['browserName'] = 'chrome'
desired_cap['loggingPrefs'] = {'performance': 'INFO'}
desired_cap['options'] = chrome_opts.to_capabilities()
self.driver = webdriver.Chrome(service = Service('/usr/local/bin/chromedriver'), options = chrome_opts, desired_capabilities=desired_cap)
And with the second code I am getting: "errorMessage": "Message: unknown error: Chrome failed to start: exited abnormally.\n (unknown error: DevToolsActivePort file doesn't exist)\n (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.
chrome_opts = Options()
chrome_opts.add_argument("--allow-running-insecure-content")
if 'DOCKER_AUTH_CONFIG' in os.environ:
chrome_opts.add_argument('--headless')
chrome_opts.add_argument('--no-sandbox')
chrome_opts.add_argument('--disable-dev-shm-usage')
self.headless = True
chrome_opts.add_argument("window-size=1920,1080")
chrome_opts.binary_location = '/usr/bin/google-chrome'
chrome_opts.add_experimental_option('w3c', False) # Needed for chromedriver 75 (logging doesn't work in w3c mode)
desired_cap = {}
desired_cap['platform'] = 'ANY'
desired_cap['browserName'] = 'chrome'
desired_cap['loggingPrefs'] = {'performance': 'INFO'}
desired_cap['options'] = chrome_opts.to_capabilities()
self.driver = webdriver.Chrome(service = Service('/usr/local/bin/chromedriver'), desired_capabilities=desired_cap)
I don't know honestly what error is better than the other, I tried to play with many options according to what I found in the web.
Can somebody help me solve this issue and understand it please.
---- Update:
Now I am getting this error after using:
WebDriverException: Message: unknown error: unable to discover open window in chrome
(Session info: headless chrome=103.0.5060.114)
chrome_opts = Options()
chrome_opts.add_argument("--allow-running-insecure-content")
chrome_opts.add_argument('--headless')
chrome_opts.add_argument('--no-sandbox')
chrome_opts.add_argument('--disable-dev-shm-usage')
chrome_opts.add_argument('--remote-debugging-port=9222')
self.headless = True
# chrome_opts.add_argument("window-size=1920,1080")
# chrome_opts.add_experimental_option('w3c', False) # Needed for chromedriver 75 (logging doesn't work in w3c mode)
caps = webdriver.DesiredCapabilities.CHROME.copy()
caps['acceptInsecureCerts'] = True
print('caps')
self.driver = webdriver.Chrome(options= chrome_opts, desired_capabilities=caps)

MySql.Data.MySqlClient.MySqlException (0x80004005): Fatal error encountered attempting to read the resultset

Reading from the stream has failed.
System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I am getting this error specifically for a particular Stored procedure ( multiple queries and SP run successfully). Connection has default timeout of 30 sec, and the query takes not more than 5 sec to run. Strange thing is that if I rerun the query(by refreshing the application) I don't get the error, even if I try multiple times.
using (MySqlConnection ms = new MySqlConnection(
ConfigureData.Configuration.GetSection("ConnectionStrings")["DefaultConnection"]))
{
ms.Open();
using (MySqlCommand cmd = new MySqlCommand())
{
cmd.Connection = ms;
MySqlParameter c= new MySqlParameter("#cc", c);
cmd.CommandText = "GetList";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add(c);
MySqlDataReader reader = (MySqlDataReader)await cmd.ExecuteReaderAsync();
if (reader.HasRows)
{
// rest of the code
reader.Close();
}
}
ms.Close();
}

Not able to create mysql user with AWSAuthenticationPlugin with terraform

I am trying to create a MySQL user to use with IAM, and I am using terraform to do this.
This is what I am trying to accomplish :
CREATE USER 'lambda' IDENTIFIED WITH AWSAuthenticationPlugin as 'RDS';
with
provider "mysql" {
alias = "kadamb-test"
endpoint = "${aws_db_instance.kadamb-test.endpoint}"
username = "${aws_db_instance.kadamb-test.username}"
password = "${aws_db_instance.kadamb-test.password}"
}
resource "mysql_user" "kadamb-test-iam-user" {
provider = "mysql.kadamb-test"
user = "kadamb_test_user"
host = "%"
auth_plugin = "AWSAuthenticationPlugin"
tls_option = ""
}
This is the output when I am running terraform-apply:
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ mysql_user.kadamb-test-iam-user
id: <computed>
auth_plugin: "AWSAuthenticationPlugin"
host: "%"
user: "kadamb_test_user"
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
mysql_user.kadamb-test-iam-user: Creating...
auth_plugin: "" => "AWSAuthenticationPlugin"
host: "" => "%"
user: "" => "kadamb_test_user"
Error: Error applying plan:
1 error(s) occurred:
* mysql_user.kadamb-test-iam-user: 1 error(s) occurred:
* mysql_user.kadamb-test-iam-user: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
I am reading the documentation and trying to debug what is going wrong, but couldn't find anything.
Can anyone help me with this?
Just changing tls_option = "" to tls_option = "NONE", solved my problem.
I am not sure, how and what difference did it make, but I was able to create the user with this.

Can not connect to MySQL with CodeIgniter. Possible DNS issue?

I am running a dev LAMP with Codeigniter. However, when I try to load the page, the database can not connect(the database is actually on another server) and I get this error:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346
My database.php is this:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'myhost.com';
$db['default']['username'] = 'myusername';
$db['default']['password'] = 'mypassword';
$db['default']['database'] = 'mytable';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
If I change the 'pconnect' and/or 'db_debug' to false, I get the same error or it just doesn't work. I know the database is up and running correctly because others are able to connect and use it.
However, if I put the IP address of the host into the database.php file, it works.
I tried flushing the DNS and even changed to Google's DNS servers to no avail.
The result of a simple mysql_connect is:
A PHP Error was encountered
Severity: Warning
Message: mysql_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known
Filename: config/database.php
Line Number: 67
A PHP Error was encountered
Severity: Warning
Message: mysql_connect(): [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known (trying to connect via tcp://myhost.com:3306)
Filename: config/database.php
Line Number: 67
A PHP Error was encountered
Severity: Warning
Message: mysql_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known
Filename: config/database.php
Line Number: 67
Could not connect: php_network_getaddresses: getaddrinfo failed: Name or service not known
Try change this
$db['default']['db_debug'] = TRUE;
to this:
$db['default']['db_debug'] = FALSE;
Ensure that the domain name is registered to the correct I.P. address and your host has the record of this exact address. Try placing a static HTML file on the website, all you need is something that displays maybe the text "Hello World" to ensure that you are able to access the website via the domain name.
Ensure that you have inserted the domain name correctly in the script and that you can log in to PHPMyAdmin (or whatever you use) with the required credentials via copy and paste (without leading and trailing whitespace, be careful of that).
If it is a problem with the table name, it should say so. As for the rest of the settings, I am not familiar with any of them, but what I have outlined here should see your database working.
Good luck.

MySQL Connection Timeout Issue - Grails Application on Tomcat using Hibernate and ORM

I have a small grails application running on Tomcat in Ubuntu on a VPS. I use MySql as my datastore and everything works fine unless I leave the application for more than half a day (8 hours?). I did some searching and apparently this is the default wait_timeout in mysql.cnf so after 8 hours the connection will die but Tomcat won't know so when the next user tries to view the site they will see the connection failure error. Refreshing the page will fix this but I want to get rid of the error altogether. For my version of MySql (5.0.75) I have only my.cnf and it doesn't contain such a parameter, In any case changing this parameter doesn't solve the problem.
This Blog Post seems to be reporting a similar error but I still don't fully understand what I need to configure to get this fixed and also I am hoping that there is a simpler solution than another third party library. The machine I'm running on has 256MB ram and I'm trying to keep the number of programs/services running to a minimum.
Is there something I can configure in Grails / Tomcat / MySql to get this to go away?
Thanks in advance,
Gav
From my Catalina.out;
2010-04-29 21:26:25,946 [http-8080-2] ERROR util.JDBCExceptionReporter - The last packet successfully received from the server was 102,906,722 milliseconds$
2010-04-29 21:26:25,994 [http-8080-2] ERROR errors.GrailsExceptionResolver - Broken pipe
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
...
2010-04-29 21:26:26,016 [http-8080-2] ERROR util.JDBCExceptionReporter - Already closed.
2010-04-29 21:26:26,016 [http-8080-2] ERROR util.JDBCExceptionReporter - Already closed.
2010-04-29 21:26:26,017 [http-8080-2] ERROR servlet.GrailsDispatcherServlet - HandlerInterceptor.afterCompletion threw exception
org.hibernate.exception.GenericJDBCException: Cannot release connection
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Already closed.
at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:84)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)
... 1 more
Referring to this article, you have stale connections in your DBCP connections pool that are silently dropped by OS or firewall.
The solution is to define a validation query and do a sanity check of the connection before you actually use it in your application.
In grails this is actually done by modifying the grails-app/conf/spring/Resource.groovy file and add the following:
beans = {
dataSource(BasicDataSource) {
//run the evictor every 30 minutes and evict any connections older than 30 minutes.
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
//test the connection while its idle, before borrow and return it
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
In grails 1.3.X, you can modify the evictor values in the DataSource.groovy file to make sure pooled connections are used during idle. This will make sure the mysql server will not time out the connection.
production {
dataSource {
pooled = true
// Other database parameters..
properties {
maxActive = 50
maxIdle = 25
minIdle = 5
initialSize = 5
minEvictableIdleTimeMillis = 1800000
timeBetweenEvictionRunsMillis = 1800000
maxWait = 10000
}
}
A quick way to verify this works is to modify the MySQL my.cnf configuration file [mysql] element and add wait_time parameter with a low value.
Try increasing the number of open MySQL connections by putting the following in your DataSources.groovy:
dataSource {
driverClassName = "com.mysql.jdbc.Driver"
pooled=true
maxActive=10
initialSize=5
// Remaining connection params
}
If you want to go the whole hog, try implementing a connection pool; here is a useful link on this.
For grails 1.3.X, I had to add the following code to Bootstrap.groovy :
def init = {servletContext ->
def ctx=servletContext.getAttribute(ApplicationAttributes.APPLICATION_CONTEXT)
//implement test on borrow
def dataSource = ctx.dataSource
dataSource.targetDataSource.setMinEvictableIdleTimeMillis(1000 * 60 * 30)
dataSource.targetDataSource.setTimeBetweenEvictionRunsMillis(1000 * 60 * 30)
dataSource.targetDataSource.setNumTestsPerEvictionRun(3)
dataSource.targetDataSource.setTestOnBorrow(true)
dataSource.targetDataSource.setTestWhileIdle(true)
dataSource.targetDataSource.setTestOnReturn(false)
dataSource.targetDataSource.setValidationQuery("SELECT 1")
}
I also had to import org.codehaus.groovy.grails.commons.ApplicationAttributes
Add these parameters to dataSource
testOnBorrow = true
testWhileIdle = true
testOnReturn = true
See this article for more information
http://sacharya.com/grails-dbcp-stale-connections/
Starting from grails 2.3.6 default configuration already has options for preventing closing connection by timeout
These are the new defaults.
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
....
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
What does your JDBC connection string look like? You can set an autoReconneect param in your data source config, e.g.
jdbc:mysql://hostname/mydb?autoReconnect=true