Windows Azure Storage Exception with Connection String Specifying Account Name and Account Key - azure-storage

I am adding Windows Azure Storage to my ASP.Net application. I am using NetStandard 1.4 and am building on MacOS.
I have the following as my connection string, as recommended by learn.microsoft.com:
DefaultEndpointsProtocol=http;AccountName=XXXXXX;AccountKey=XXXXXX
I am connecting with a new Azure Storage account and have confirmed that my account name and account key are correct. Right before the call to create the table, I added a WriteLine to display the CloudStorageAccount's connection string URI just to make sure it is correct. It has the hostname.
I am getting the following error when performing "dotnet run".
Unhandled Exception: System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.AggregateException: One or more errors occurred. (An error
occurred while sending the request.) --->
Microsoft.WindowsAzure.Storage.StorageException: An error occurred
while sending the request. ---> System.Net.Http.HttpRequestException:
An error occurred while sending the request. --->
System.Net.Http.CurlException: Couldn't resolve host name
Setting explicit table storage endpoint (TableEndpoint=XXX.table.core.windows.net) didn't work either.
Are there any other reasons why Curl will fail when connecting to XXX.table.core.windows.net?

To try capture the network trace for troubleshooting? And try to ping XXX.table.core.windows.net? Is it because the DNS cache not refreshed?

Related

SSRS 403 forbidden from .NET application

We have a .NET application that is already working in a number of development and production environments. One part opens SSRS reports, one new server is giving me this error when it tries to run. I have double checked the installation of our application and done a bunch of troubleshooting including reinstalling SSRS. Any suggestions on how to troubleshoot further?
System.Web.HttpUnhandledException (0x80004005): Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.Net.WebException: The request failed with HTTP status 403:
Forbidden.

PushSharp APNS production: The credentials supplied to the package were not recognized (development works fine though)

My app just got ready for sale on App Store, but none of my production devices (devices that have installed the app from App Store) are getting push notifications. When I try to send a push notification to a production device, I am getting this error:
"The credentials supplied to the package were not recognized"
(System.ComponentModel.Win32Exception)
This exception is internally thrown and caught in an infinite loop:
It is thrown at line 539 of ApplePushChannel.cs file:
try
{
stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates,
System.Security.Authentication.SslProtocols.Ssl3, false);
//stream.AuthenticateAsClient(this.appleSettings.Host);
}
catch (System.Security.Authentication.AuthenticationException ex)
{
throw new ConnectionFailureException("SSL Stream Failed to Authenticate as Client", ex);
}
This is the output of the application in Visual Studio Output:
...
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
...(it keeps getting thrown until I stop it manually)
Here are the things I've tried:
Double checked that the device ID I'm trying is registered with a production device token.
Revoked and regenerated the APNS Production certificate, exported it with the private key to a new .p12 file, and tried again with the new certificate. (I had the same problem with development push notifications, and this solved my problem)
Changed the SSL protocol from Ssl3 to Tls. (a few days ago there was a problem with protocol version, and it fixed a problem temporarily. There shouldn't be need for this, but the error I'm getting is the same as the one I was getting before which this fixed)
Checked that I'm actually trying to connect to production server with the production certificate instead of development server/certificate.
Checked that I can access the APNS server directly (my ASP.NET app lives inside a Parallels VM Windows 8.1 at my Mac, here is the output from my Mac, just to avoid confusion:
(Terminal output)
Edit: I was pinging the sandbox server, I've pinged the production server, I verify that I can connect to it too, so it's not the issue.
can$ sudo nmap -p 2195 gateway.sandbox.push.apple.com
Starting Nmap 6.40-2 ( http://nmap.org ) at 2014-04-28 00:06 EEST
Nmap scan report for gateway.sandbox.push.apple.com (17.149.34.189)
Host is up (0.49s latency).
Other addresses for gateway.sandbox.push.apple.com (not scanned): 17.149.34.187 17.149.34.188
PORT STATE SERVICE
2195/tcp open unknown
Why would PushSharp not negotiate with APNS servers?
I figured out the problem. I revoked and regenerated the certificate again, and this time I only exported the private key (without the certificate). In Keychain access, I exported as .p12 and used the new file and it worked. For some reason, PushSharp wasn't play well with .p12 when both certificate and private key are present in the file.
"The credentials supplied to the package were not recognized" exception usually indicates that the user running the code does not having enough permissions.
If you are sending push notifications from Azure web app or webjob do not load the APNS certificate from a file or base64-encoded string. Go to Azure Portal and add the certificate to website instead. Note the thumbprint.
Next add WEBSITE_LOAD_CERTIFICATES setting and set it to * (asterisk).
Now the APNS certificate can be used from C# code:
string thumbprint = "YOUR THUMBPRINT";
var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
var certificate = store.Certificates.Find(
X509FindType.FindByThumbprint, thumbprint, validOnly: false)
.Cast<X509Certificate2>().SingleOrDefault();
var apnsConfig = new ApnsConfiguration(
ApnsConfiguration.ApnsServerEnvironment.Production, certificate);
References
Using Certificates in Azure Websites Applications
Configuring a certificate for APNS on the Azure platform
When using the windows certificate store, (imho the easiest way to manage certificates on a production server), be sure to set the correct permissions on the private key.
None of the answers worked for me. In the end what I ended up doing is importing the Cert and Private Key into the Windows cert store, and then exporting as a .pfx.
I was tested it again and again.
Convert the p12 file to pem format, and it will work with IIS limited users and maybe with Azure....
I was receiving the same exception and in my case I had to add permission for my IOS Push Services certificate.
Right click on the certificate in mmc -> All Tasks -> Manage Private Keys...
I added NETWORK SERVICE because the iis application pool of my web app used that account.
See for more details: http://blog.falafel.com/apple-push-notifications-certificates-and-iis/

Liferay stopped at database shutdown caused a crash

I was stopping the Liferay portal, but few seconds after, I stopped the database (db2 quiesce, that means, that the connections are closed) and apparently, Liferay did not stopped correctly its execution.
After that, I restarted the database and liferay, but the portal does not work now. It shows this message in the browser:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
...
root cause
java.lang.NoSuchMethodError: com.liferay.portal.util.PortalUtil.getCDNHostHttp()Ljava/lang/String;
com.liferay.portal.events.ServicePreActionExt.servicePre(ServicePreActionExt.java:937)
After looking in the logs, I found the following messages (they are edited):
SEVERE: Error waiting for multi-thread deployment of directories to completehostConfig.deployWar=Deploying web application archive {0}
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1000)
WARN [DefaultConnectionTester:203] SQL State '08001' of Exception which occurred during a Connection test (fallback DatabaseMetaData test) implies that the database is invalid, and the pool should refill itself with fresh Connections.
com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2030][11211][3.63.75] A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream. Error location: Reply.fill() - insufficient data (-1). Message: Insufficient data. ERRORCODE=-4499, SQLSTATE=08001
at com.ibm.db2.jcc.am.fd.a(fd.java:321)
WARN [DefaultConnectionTester:136] SQL State '08001' of Exception tested by statusOnException() implies that the database is invalid, and the pool should refill itself with fresh Connections.
WARN [C3P0PooledConnectionPool:708] A ConnectionTest has failed, reporting that all previously acquired Connections are likely invalid. The pool will be reset.
WARN [NewPooledConnection:486] [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
WARN [NewPooledConnection:487] [c3p0] Another error has occurred [ com.ibm.db2.jcc.am.SqlNonTransientConnectionException: [jcc][t4][10335][10366][3.63.75] Invalid operation: Connection is closed. ERRORCODE=-4470, SQLSTATE=08003 ] which will not be reported to listeners!
com.ibm.db2.jcc.am.SqlNonTransientConnectionException: [jcc][t4][10335][10366][3.63.75] Invalid operation: Connection is closed. ERRORCODE=-4470, SQLSTATE=08003
WARN [BasicResourcePool:1841] com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask#4fad5112 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (3). Last acquisition attempt exception:
com.ibm.db2.jcc.am.SqlNonTransientConnectionException: DB2 SQL Error: SQLCODE=-20157, SQLSTATE=08004, SQLERRMC=FUT5MAN;QUIESCE DATABASE;;, DRIVER=3.63.75
ERROR [PortalJobStore:109] MisfireHandler: Error handling misfires: Unexpected runtime exception: null
org.quartz.JobPersistenceException: Unexpected runtime exception: null [See nested exception: java.lang.reflect.UndeclaredThrowableException]
Caused by: java.lang.reflect.UndeclaredThrowableException
at $Proxy279.prepareStatement(Unknown Source)
at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.countMisfiredTriggersInState(StdJDBCDelegate.java:413)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
Now, I see that it is almost impossible to start the current Liferay installation. However, I have the database (I made a full backup), and the lucene's data directory. How can I recreate a Liferay installation with these two things? I would like to recover some of this data in a new installation, but I do not how.
This is not the best solution, but I installed Liferay with a new database. Once it was configured, I change the database configuration in order to use the other one.
Probably, it was a problem with the ROOT deployment, but this is very weird.
I could recover all the data from the Lucene and the database.
The database is still quiesced and the Liferay user doesn't have the QUIESCE_CONNECT privilege.
Unquiesce the database and restart Liferay.
Using DB2 instance owner (if you're on Windows, any administrator):
db2 connect to DBNAME
db2 unquiesce database
db2 connect reset
Regards.

Cassia Library giving exception when calling any methods

I am trying to run the Cassia library on a remote Windows Server 2008 Terminal Server. Any methods I call I get the response below.
No more data is available
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: No more data is available
Stack Trace:
[Win32Exception (0x80004005): No more data is available]
Cassia.Impl.NativeMethodsHelper.GetSessionInfos(ITerminalServerHandle server) +159
Cassia.Impl.TerminalServer.GetSessions() +103
I was getting this error as well. Turns out that if there are no sessions for the given server it throws this exception.
Try running qwinsta /server <servername> in a WCP shell. It should return "No session exists for *".
I worked around this by checking exception message for "no more data" and don't throw it if so. It's gross but it's an open source dll.

Service reference error when moving dev. environment from XP to W7

I am building an application and I am using web services for getting data from a server. It was working fine when I was developing on my XP machine but had to switch to Windows 7. On the new machine I grabbed the latest version of the code using sourcesafe.
However, when I try to add a service reference in the solution or update an existing one I get the following error:
There was an error downloading 'http://localhost:52490/Service/CustomerService.asmx'.
The request failed with the error message:
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not create type 'Digital_Server.CustomerService'.
Source Error
Source File: /Service/CustomerService.asmxLine: 1
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
--.
Metadata contains a reference that cannot be resolved: 'http://localhost:52490/Service/CustomerService.asmx'.
An error occurred while receiving the HTTP response to http://localhost:52490/Service/CustomerService.asmx. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
If the service is defined in the current solution, try building the solution and adding the service reference again.
Does it has anything to do with the IIS or is it any configuration file I have to change in the solution?
Any help is appreciated.
How do you deploy your app to the server? Via a zip file?
Perhaps it extracts the files without the path.