Posts

AWS Aurora "Reading from the stream has failed" Error

We had problem with Aurora SQL throwing error when it is in sleep (pause) mode. By default, it is set to sleep when idle for 5 minutes. After few attempts, we managed to extend the timeout which is command timeout (not to be confused with connection timeout) to 60s in our case to prevent the error from happening. The timeout can be set in connection string: Server=server;Database=database;Uid=username;Pwd=password; Default Command Timeout=60 Reference: https://www.connectionstrings.com/mysql-connector-net-mysqlconnection/specifying-default-command-timeout/ Update 12/3/2019 The above didn't work somehow on our ASP.NET application that used EntityFramework, so we have to specify it in our ApplicationDbContext constructor and increase it to 5 minutes (300s). The following is the VB.NET version: Public Sub New(existingConnection As Common.DbConnection, contextOwnsConnection As Boolean) MyBase.New(existingConnection, contextOwnsConnection) Database.CommandTim...

Xamarin "java.exe exited with code 2" Error

Bumped into the following error  "java.exe exited with code 2" when building Xamarin app today. The only thing change is I added a Syncfusion NuGet package. I managed to solve it by enabling MultiDex. Reference: https://forums.xamarin.com/discussion/97803/getting-error-java-exe-exited-with-code-2 https://developer.android.com/studio/build/multidex

Salesforce CPQ Lightning Template Content Font Color

Somehow I was involved in trying to change the font color in Salesforce CPQ template content. Seems easy but it is not working the way we want. We selected HTML as the content type and it comes with a nice rich text editor. As we change the font color, it looks great on the page. However, when we attach the template content to the quote template and preview the quote with that template, couple of things occurs: The font color is gone and reflected back to black It puts the next words which is supposed to be different color in a new line We double-checked the HTML and can't find anything wrong with it. So I decided to check which engine generates the quote preview PDF and found out that it is using Apache FOP. The fun thing is it Apache FOP doesn't support HTML inherently, but it does support XSL, so

Model Binding Issue ASP.NET Core in Ubuntu using Postman

I spent a fair amount of time trying to troubleshoot my ASP.NET Core web server in Ubuntu. The issue starts when I noticed a failed model binding in Ubuntu using HTTP PUT method when it works locally on my Window machine. I also found out that it binds properly when I used HTTPS compared to HTTP. Looking into the server, I have configured Nginx as reverse proxy server which send a 301 Redirect to HTTPS when the request is made using HTTP. I can't find any issue on the web application itself, Nginx, so I decided to check Postman which I used to generate the request. I found out that by default, Postman always follows redirect. There is nothing wrong with that, except seems like the data is lost during redirect. Eventually I found out that, 301 is meant to be used with GET and thus any POST/PUT data will be scrapped during redirect. Hence, it is the correct logic all along.

Method not found System.Net.Http.HttpContentExtensions.ReadAsAsync

Bumped into this error when moving my web app to another server. It happened to me before but this time the cause is different. So two ways that worked for me: 1. Install package Microsoft.AspNet.WebApi.Client. This will provide access to HttpFormatting.dll which actually contains the ReadAsAsync method and fixed the issue for me before. 2. I found out that my System.Net.Http was not referenced properly because it depends on the dll installed in the machine. So, installing System.Net.Http NuGet package fix the current issue for me.

Where is My Environment Variables? Journey to Linux Service

Ok, I had a .NET Core Web App running in Ubuntu behind Nginx. Everything else is fine except I can't retrieve the value of the environment variables that I put in /etc/environment. After hours of googling, turns out systemd service strips all out except some variables. Two ways to fix this: 1. Put the environment variable in the .service config file [Service] Environment=MY_ENV_VAR=thevalue 2. Include /etc/environment in the service. (I don't think this is a good idea, especially for my use case). [Service] EnvironmentFile=/etc/environment

AWS SSM Linux Shell Script Closing Paren Expected Error

I ran my scripts through AWS SSM and received the "closing paren expected" error message. Quick check on my code, I was missing items in two different situations: 1. I was missing closing parentheses \), so adding it solves the issue. My code was like: if [ \( <expr> ]; then <do this>; fi 2. My closing parentheses was not prefixed by space, so adding a space fixed it. It was like: if [ \( <expr> \) ]; then <do this>; fi